Keeping your Linux system updated is arguably the single most important administrative task you can perform. Updates provide critical security patches that protect your machine from vulnerabilities, deliver performance improvements, and introduce new software features.
While desktop versions of Ubuntu offer a graphical “Software Updater” application that occasionally prompts you to install updates, relying on the GUI is inefficient and completely useless if you are managing a headless Ubuntu server over SSH. The command line offers a significantly faster, more transparent, and more powerful way to manage your system’s packages using the APT (Advanced Package Tool) package manager.
Understanding the Two-Step Update Process
A common mistake made by Linux beginners is assuming that updating a system is a single action. In Ubuntu (and all Debian-based distributions), updating your system securely requires two distinct commands executed in a specific order: update and upgrade.
- Update: This command does not install any new software. Instead, it contacts the official Ubuntu software repositories on the internet, downloads the latest list of available software versions, and compares it to what is currently installed on your local machine. It is essentially refreshing the catalogue.
- Upgrade: This command actually performs the installation. It looks at the refreshed catalogue and downloads and installs the newer versions of any outdated software on your machine.
Step 1: Refresh the Package Lists (Update)
You must always run this command first to ensure your system knows about the latest patches.
- Open your terminal application (Ctrl + Alt + T on a desktop environment).
- Type the following command:
sudo apt update - Press Enter.
- You will be prompted to enter your administrator password. When you type, no characters or asterisks will appear on the screen. This is a standard Linux security feature. Just type the password blindly and press Enter.
The terminal will display a scrolling list of URLs as it contacts various Ubuntu servers. Once finished, it will summarize the results, typically stating something like, “All packages are up to date” or “14 packages can be upgraded.“
Step 2: Install the New Software (Upgrade)
If the previous command indicated that upgrades are available, you can now proceed to install them.
- In the terminal, type:
sudo apt upgrade - Press Enter.
The system will calculate the changes and display a detailed summary. It will list exactly which software packages will be updated, which new dependencies will be installed, and how much data needs to be downloaded over your internet connection.
At the bottom of the summary, you will see a prompt asking: Do you want to continue? [Y/n]
Simply type Y (for yes) and press Enter. The system will now download the necessary files, unpack them, and seamlessly install the updates over your existing software. Depending on the size of the updates, this process can take anywhere from a few seconds to several minutes.
How to Do Both Steps with One Command
Once you are comfortable with the two-step process, you can combine both commands into a single, highly efficient terminal string using the logical AND operator (&&) and the auto-yes flag (-y).
Type the following command and press Enter:
sudo apt update && sudo apt upgrade -y
This tells the system: “First, refresh the package lists. If, and only if, that succeeds without errors, proceed to calculate the upgrades. Furthermore, automatically answer ‘Yes’ to the confirmation prompt.” This allows you to walk away from the computer while it handles the entire update process automatically.
What is “dist-upgrade” or “full-upgrade”?
Occasionally, a standard sudo apt upgrade will hold back certain packages and refuse to install them. This happens when an update requires the removal of existing packages to resolve a complex dependency conflict (which a standard upgrade is forbidden from doing).
To force these stubborn updates through, you must use the full upgrade command:
sudo apt full-upgrade (or sudo apt dist-upgrade on older systems).
Warning: Always read the summary prompt carefully before pressing “Y” when using this command. Ensure it is not attempting to remove a critical piece of software you rely on to resolve a conflict.