If you want, you can run these three commands together,
sudo apt-get update
sudo apt-get -y dist-upgrade
sudo apt-get autoremove
The first one resynchronizes the package index files from their sources. The second one
in addition to performing the function of upgrade, also intelligently handles changing dependencies with new versions of packages.
apt-get has a smart conflict resolution system, and it will attempt to upgrade the most important packages at the expense of less important ones if necessary. And finally, the third one removes packages that were automatically installed to satisfy dependencies for other packages and are now no longer needed.
Actually, I have put the three commands together under one
alias. See below,
alias updatedistupgrade='sudo apt-get update; sudo apt-get -y dist-upgrade; sudo apt-get autoremove'
All I do is to run
updatedistupgrade from time to time. So, in my system, the unnecessary files are never there.
to get more information.