How to update Ubuntu from the command line - Rocketeers app

  [ Rocketeers ](/)   

[Login](https://rocketeersapp.com/login) 

 On this page

 Knowledge
---------

How to update Ubuntu from the command line
==========================================

### [\#CommandLine](https://rocketeersapp.com/knowledge/command-line)

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](https://rocketeersapp.com/author/mark-van-eijk) on June 23, 2026 · 1 minute read

1. [Update vs upgrade: the part everyone confuses](#content-update-vs-upgrade-the-part-everyone-confuses)
2. [Refresh the package lists](#content-refresh-the-package-lists)
3. [Install the available updates](#content-install-the-available-updates)
4. [When upgrade isn't enough: full-upgrade](#content-when-upgrade-isnt-enough-full-upgrade)
5. [Updating a single package](#content-updating-a-single-package)
6. [Clean up afterwards](#content-clean-up-afterwards)
7. [Upgrading to a new Ubuntu release](#content-upgrading-to-a-new-ubuntu-release)
8. [The one-liner I actually use](#content-the-one-liner-i-actually-use)

[\#](#content-update-vs-upgrade-the-part-everyone-confuses "Permalink")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.

[\#](#content-refresh-the-package-lists "Permalink")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.

[\#](#content-install-the-available-updates "Permalink")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

```

[\#](#content-when-upgrade-isnt-enough-full-upgrade "Permalink")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.

[\#](#content-updating-a-single-package "Permalink")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

```

[\#](#content-clean-up-afterwards "Permalink")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](/reclaim-diskspace-on-ubuntu), since stale kernels eat into `/boot`.

[\#](#content-upgrading-to-a-new-ubuntu-release "Permalink")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](/check-ubuntu-version-command-line). Add `-d` only if you specifically want to upgrade to a development release.

[\#](#content-the-one-liner-i-actually-use "Permalink")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!

  Fill in your email address to receive updates  Subscribe 

#### More in [\#CommandLine](https://rocketeersapp.com/knowledge/command-line)

- [Argument list too long (Bash: /bin/rm)](https://rocketeersapp.com/knowledge/argument-list-too-long)
- [How to install Composer packages locally](https://rocketeersapp.com/knowledge/install-composer-packages-locally)
- [How to send GET and POST requests with curl](https://rocketeersapp.com/knowledge/curl-post-get-api-requests)
- [Essential Linux command line basics for developers](https://rocketeersapp.com/knowledge/linux-command-line-basics)
- [How to search file contents with grep](https://rocketeersapp.com/knowledge/search-files-grep-command)
- [The complete guide to the curl command](https://rocketeersapp.com/knowledge/curl-command-complete-guide)

 [View all 21 articles →](https://rocketeersapp.com/knowledge/command-line)
