Updating and Upgrading Linux Packages
This post explains how to keep a Linux system up to date using the apt package manager. It covers the difference between apt update and apt upgrade, walks through real terminal output, and introduces full-upgrade and command chaining for efficiency.
One of the most important habits you can build as a Linux user is keeping your system up to date. Whether you are running Ubuntu on a personal laptop or a server in a data centre, regularly updating your packages protects you from security vulnerabilities, fixes bugs, and ensures you have access to the latest features. The good news is that Linux makes this process straightforward once you understand what is happening under the hood.
Understanding Package Management
Linux software is distributed and managed through a package manager. Think of it as an app store, except it is command-line driven and handles all the dependencies automatically. On Debian-based distributions like Ubuntu, the package manager is apt (Advanced Package Tool). On Red Hat-based systems like Fedora or CentOS, you would use dnf or yum, where the equivalent commands are dnf check-update and dnf upgrade. This post focuses on apt, which is what most beginners encounter first.
Packages are downloaded from repositories, which are remote servers that host software. Your system keeps a local list of available packages from these repositories. Before you can upgrade anything, you need to refresh that list.
The Difference Between Update and Upgrade
These two words are often confused, but they do very different things:
- Update refreshes your local package index. It does not install or change any software. It just checks the repositories and downloads the latest list of available versions.
- Upgrade actually installs the newer versions of packages that are already installed on your system.
You should always run update before upgrade, otherwise you might be upgrading based on an outdated package list.
Running the Commands
Both commands require elevated privileges, so you will use sudo. If you are new to the term, sudo (short for "superuser do") lets a permitted user run a command with administrator-level permissions, similar to "Run as administrator" on Windows. Open your terminal and run the commands in order:
sudo apt updateYou will see output that looks something like this:
Hit:1 http://gb.archive.ubuntu.com/ubuntu jammy InRelease
Get:2 http://gb.archive.ubuntu.com/ubuntu jammy-updates InRelease [119 kB]
Get:3 http://security.ubuntu.com/ubuntu jammy-security InRelease [110 kB]
Fetched 229 kB in 2s (114 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
42 packages can be upgraded. Run 'apt list --upgradable' to see them.That final line tells you how many packages have updates available. Now run the upgrade:
sudo apt upgradeYou will be shown a summary of what will be changed and prompted to confirm:
The following packages will be upgraded:
curl git nano openssh-client wget
5 upgraded, 0 newly installed, 0 to remove and 37 not upgraded.
Need to get 4,521 kB of archives.
After this operation, 12.3 kB of additional disk space will be used.
Do you want to continue? [Y/n]Press Y and hit Enter to proceed. Linux will download and install the updates automatically.
Full Upgrade vs Standard Upgrade
There is a third command worth knowing: sudo apt full-upgrade. This is equivalent to apt-get dist-upgrade, a command you may have seen referenced in older guides. Unlike upgrade, which will not remove packages in the vast majority of cases, full-upgrade is allowed to remove packages if that is needed to resolve dependency conflicts during the upgrade. In most day-to-day situations, upgrade is fine. Reserve full-upgrade for when a standard upgrade leaves packages held back.
Combining the Commands
Once you are comfortable, you can chain these commands together on one line to save time:
sudo apt update && sudo apt upgrade -yThe && means the second command only runs if the first one succeeds. The -y flag automatically answers "yes" to any prompts, so the upgrade runs without interruption. This is a common pattern you will see used in scripts and automation.
How Often Should You Update?
On a personal machine, once a week is a solid habit. On a server, many administrators set up automated updates for security patches using the unattended-upgrades package. The key is consistency. An unpatched system is a vulnerable system.
What's Next
Now that you know how to keep your system current, the next logical step is understanding how to install and remove specific packages using apt install and apt remove. You will also learn how to search for packages from the command line, so you can find the right tool for any job without leaving your terminal.