Knowledge

How to update Ubuntu from the command line

#CommandLine

Learn the difference between apt update and apt upgrade, how to install all updates, clean up old packages, and upgrade to a new Ubuntu release.

Published by Mark van Eijk on June 23, 2026 · 1 minute read

  1. Update vs upgrade: the part everyone confuses
  2. Refresh the package lists
  3. Install the available updates
  4. When upgrade isn't enough: full-upgrade
  5. Updating a single package
  6. Clean up afterwards
  7. Upgrading to a new Ubuntu release
  8. The one-liner I actually use

Update vs upgrade: the part everyone confuses

The single most common mix-up with apt is thinking update installs new software. It doesn't. apt update only refreshes the list of available packages, while apt upgrade actually installs the newer versions. You almost always run them as a pair.

Refresh the package lists

First, sync the local index of what's available from Ubuntu's repositories:

sudo apt update

This downloads nothing but metadata. After it runs, apt will often tell you how many packages can be upgraded. Nothing on your system has changed yet.

Install the available updates

Now apply them:

sudo apt upgrade

apt upgrade installs newer versions of packages you already have. By design it won't remove anything or install brand-new dependencies. To skip the confirmation prompt, add -y:

sudo apt upgrade -y

When upgrade isn't enough: full-upgrade

Sometimes an update needs to remove an obsolete package or pull in a new dependency, for example a new kernel. Plain upgrade holds those back. full-upgrade (the modern name for dist-upgrade) allows it:

sudo apt full-upgrade

I run this for kernel and major library updates. Both full-upgrade and dist-upgrade do the same thing.

Updating a single package

If you only want to bump one package, name it after install. It upgrades just that package (and its dependencies) to the latest available version:

sudo apt install --only-upgrade nginx

Clean up afterwards

Old kernels and orphaned dependencies pile up over time. Remove what's no longer needed:

sudo apt autoremove

This is one of the first things I do when I reclaim disk space on Ubuntu, since stale kernels eat into /boot.

Upgrading to a new Ubuntu release

Everything above keeps your current release patched. To jump to a newer release, like 22.04 to 24.04, you need a different tool:

sudo do-release-upgrade

This is a major upgrade, so first make sure your current system is fully patched and check which release you're on with how to check your Ubuntu version. Add -d only if you specifically want to upgrade to a development release.

The one-liner I actually use

Day to day, I chain the common steps together:

sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y

That refreshes, installs everything, and tidies up in a single command.

Subscribe to our newsletter

Do you want to receive regular updates with fresh and exclusive content to learn more about web development, hosting, security and performance? Subscribe now!

Related articles

Argument list too long (Bash: /bin/rm)

Learn the difference between apt update and apt upgrade, how to install all updates, clean up old packages, and upgrade to a new Ubuntu release.

Read more →

How to install Composer packages locally

Learn the difference between apt update and apt upgrade, how to install all updates, clean up old packages, and upgrade to a new Ubuntu release.

Read more →