On all currently supported versions of Ubuntu, we can use
apt instead of
apt-get. If you want to capture the output in a file, use
apt-get, but otherwise use
apt as its output is more readable (and who likes typing?).
sudo apt update
Downloads information from the repositories 1 APT is configured to check, and updates the
dpkg database of available, installed, and uninstalled packages to reflect changes in the repositories. This means that when you query the database on your system with commands like
apt policy package-name
apt show package-name
apt search package-name
they will print accurate information, and when you run commands like
sudo apt install package-name
they will fetch the latest available version.
When you run
sudo apt update you may see that some packages are upgradable, meaning new versions have been added to the repositories. Newer versions often have bug fixes and security updates, so you should install them. This can be done by upgrading all packages that have new versions available with the command
sudo apt upgrade
If the kernel was upgraded (packages like
linux-image-4.15.0-20-generic) you should then run a command to remove old kernel versions (except for the second-newest which is kept as a spare, in case the new one is buggy). You can use this command:
sudo apt autoremove
to do that. This command also removed orphaned packages. These generally only exist when you use a command like
sudo apt remove package-name
package-name has dependencies that were installed along with it automatically, but are not needed by any other package.
autoclean, I refer you to
autoclean (and the auto-clean alias since 1.1)
Like clean, autoclean clears out the local repository of retrieved
package files. The difference is that it only removes package files
that can no longer be downloaded, and are largely useless.
The other three commands are really important and should generally be run regularly to keep the system secure and updated and avoid filling the disk with old kernel files, but you probably won't see much difference after running
autoclean. The few files it might delete occasionally are unlikely to amount to much.
1These repositories are configured by default, so you usually don't need to do anything with them. They are listed in the file
/etc/apt/sources.list and in files in
/etc/apt/sources.list.d. APT is strict about the format of these files (for security reasons) and will throw errors if they have bad syntax. If your system has a graphical environment, it will have an option to configure repositories in settings. You need root privilege to do that job.