How to update your Ubuntu server packages
By Flavio Copes
Learn how to keep an Ubuntu server up to date with the latest packages and security fixes, by running apt-get update, then apt-get upgrade, and rebooting.
I have a few VPS based on Ubuntu and I have an alert on my calendar to log in from time to time and update the packages and keep up with security fixes.
Here’s the sequence I use (it’s mostly a note to myself for the next time I forget)
Connect to the server with an account that can use sudo, then refresh the package index:
sudo apt update
This downloads the latest package metadata. It does not upgrade anything yet.
Now install the available upgrades:
sudo apt upgrade
Read the proposed changes before confirming. For an upgrade that may install or remove dependencies, use sudo apt full-upgrade and review the plan carefully.
Remove dependencies that are no longer needed with:
sudo apt autoremove
Then, if needed (depends on the kind of packages that needed an update), reboot the system:
sudo reboot
Ubuntu usually creates /var/run/reboot-required when an installed update requires a reboot. You can check it with test -f /var/run/reboot-required && echo "Reboot required".
Related posts about computers: