Imagine you are trying to install a new tool like nmap on your Ubuntu server, but the terminal insists the package cannot be found. Or perhaps you’ve received a notification that security patches are available, yet running a simple install command doesn’t seem to fetch the newest version. These common frustrations often stem from a misunderstanding of how Ubuntu tracks and applies software changes through its package management system.
To maintain a secure and functional system, you must master the two fundamental pillars of the Advanced Packaging Tool (APT). While they are often used together, apt update and apt upgrade perform entirely different roles in the lifecycle of your system’s software. Knowing the difference ensures you don’t just “run commands” but actually understand how to keep your Linux environment optimized and secure.
Table of Contents
Key Takeaways: Mastering APT Commands
- Package Index →
apt updaterefreshes the local database of available software metadata from the repositories. - Software Versions →
apt upgradeperforms the actual download and installation of newer package files. - Execution Order → You must always run update before upgrade to ensure you are viewing the most recent versions.
- Administrative Rights → Because these commands modify system files, using the sudo command is mandatory.
Method 1: Refreshing Metadata with apt update
The apt update command is strictly about the database. It does not install any new software or change the versions of files already on your disk. Instead, it “hits” the official Ubuntu archives to see if any bug fixes or new releases have been published since your last check.
Command: sudo apt update
Example Output:
Hit:1 http://archive.ubuntu.com/ubuntu noble InRelease
Hit:2 http://security.ubuntu.com/ubuntu noble-security InRelease
Reading package lists... Done
88 packages can be upgraded. Run 'apt list --upgradable' to see them.
This command updates the package index, which is a local list of all packages available in the repositories defined in your system configuration.
Method 2: Installing Updates with apt upgrade
Once your local database is informed about newer versions, you use apt upgrade to apply those changes to your installed packages. This command looks at the metadata you just downloaded, identifies which software has a “Candidate” version higher than what is currently installed, and lists them for your approval.
Command: sudo apt upgrade
Workflow Details: When you run this, APT will provide a transaction summary, showing the total download size and how much additional disk space will be used. You must type Y to confirm the installation. If you want to automate this in a script, you can use the -y flag to assume yes.
Method 3: Auditing Changes with apt list –upgradable
Before committing to an upgrade, it is best practice to see exactly what will change. This bridge command allows you to inspect the version numbers and hardware architecture of the pending updates.
See also: Mastering the Linux Command Line — Your Complete Free Training Guide
Command: apt list --upgradable
Example Output:
base-files/noble-updates 13ubuntu10.1 amd64 [upgradable from: 13ubuntu10]
cloud-init/noble-updates 24.2-0ubuntu1 all [upgradable from: 24.1.3]
This helps you identify if a critical package is being modified, allowing you to check file size in Linux for any logs or configs you might want to back up first.
Step-by-Step Process: Updating Your Ubuntu System
- Open your terminal and verify your internet connection.
- Synchronize your database by running
sudo apt update. - Review the upgradable list using
apt list --upgradableto see pending changes. - Execute the upgrade by running
sudo apt upgrade. - Confirm the prompt by typing Y when asked “Do you want to continue?”.
- Verify completion by checking if a system reboot is required (the file
/run/reboot-requiredwill exist if needed).
Summary Tables
| Command | Primary Role | Does it install files? | Persistence |
|---|---|---|---|
| apt update | Refreshes the package index | No | Local cache update |
| apt upgrade | Installs new software versions | Yes | Permanent install |
| apt dist-upgrade | Resolves complex dependencies | Yes | Permanent install |
| Term | Meaning | Role in Ubuntu |
|---|---|---|
| Repository | Central software archive | The source of all deb packages. |
| Package Index | Local metadata database | Stores info on version and arch. |
| Dependencies | Required helper packages | Files needed for a package to function. |
FAQs
Why must I run ‘update’ before ‘upgrade’? If you don’t run update, your system uses an old package index. It won’t know that newer versions exist in the repository, so upgrade will incorrectly report that your system is already “up to date”.
What is the difference between ‘upgrade’ and ‘dist-upgrade’? apt upgrade will never remove a package to satisfy an update. apt dist-upgrade is smarter; it can add or remove packages to resolve complex dependency conflicts, but it requires more attention from the user.
Can I run both commands at once? Yes, developers often use the && operator: sudo apt update && sudo apt upgrade -y. This ensures the second command only runs if the first one finishes successfully.

