How to Update Ubuntu from the Command Line

Keeping your Linux server updated is the single most important thing you can do to prevent security breaches. When developers discover a vulnerability in a core piece of software, they release a patch. If you do not install that patch, your server remains exposed.

While desktop versions of Ubuntu have a graphical “Software Updater” app, servers usually do not. You must manage updates using the apt package manager. Here is how to update Ubuntu from the command line in just two steps.

Step 1: Update the Package Index

Before you can install any updates, your server needs to know what updates actually exist. The apt package manager keeps a local database of all available software and their current version numbers.

You must tell your server to ping the official Canonical servers and refresh this list.

  1. Open your terminal or connect to your server via SSH.
  2. Type the following command:
    sudo apt update
  3. Press Enter and type your administrator password if prompted.

As the command runs, you will see a list of URLs scrolling down the screen as your server contacts various repositories. When it finishes, it will print a message at the bottom, such as: “24 packages can be upgraded. Run ‘apt list –upgradable’ to see them.

Crucial Note: The apt update command does not actually install any updates. It merely updates the list of what is available.

Step 2: Install the Upgrades

Now that your server has a fresh list of available patches, you can tell it to download and install them.

  1. Type the following command:
    sudo apt upgrade
  2. Press Enter.
  3. The terminal will list every single package that is about to change and tell you exactly how much disk space the update will consume.
  4. It will pause and ask, “Do you want to continue? [Y/n]”. Type Y and press Enter.

The system will now download the new files and overwrite the old ones. Depending on how many updates are pending, this could take anywhere from ten seconds to ten minutes.

Step 3: Clean Up (Optional but Recommended)

Whenever you update software, Ubuntu often downloads new dependencies and leaves the old, unused ones behind. Over time, these orphaned files can consume gigabytes of precious hard drive space.

After your upgrade finishes, it is a good habit to run the autoremove command to sweep away the garbage:

sudo apt autoremove

Press Y to confirm the deletion. Your Ubuntu system is now fully patched, secure, and clean.

Leave a Reply

Your email address will not be published. Required fields are marked *

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.

Receive our best articles and tips delivered straight to your inbox.