How to Update Ubuntu From the Command Line: APT vs do-release-upgrade for System Maintenance

0
4

Use APT for regular Ubuntu maintenance, and use do-release-upgrade when you want to move to a new Ubuntu version. That is the simple rule. Ubuntu LTS releases get five years of standard support, so you do not need to panic-upgrade every week [source: Ubuntu].

TLDR: Run sudo apt update && sudo apt upgrade for normal security fixes and app updates. Run sudo do-release-upgrade only when moving from one Ubuntu release to another, like from 22.04 LTS to 24.04 LTS. For example, a small office with 25 Ubuntu laptops might use APT weekly, but do a release upgrade once every 2 years. That means about 100 small maintenance runs for every 1 big system jump.

APT is your daily toolbox

APT is the friendly package manager behind most Ubuntu updates. It updates software. It installs tools. It removes old packages. It also fixes security patches.

Think of APT as your kitchen sponge. Not glamorous. Always useful. You use it often.

The most common command is this:

sudo apt update
sudo apt upgrade

These two commands do different jobs.

  • apt update refreshes the package list.
  • apt upgrade installs available updates.

The first command does not upgrade anything. It only checks what is available. The second command does the actual work.

Honestly, it feels like Ubuntu should make that clearer. New users run apt update and expect magic. Nope. It just reads the menu.

The basic APT maintenance routine

Here is a safe and simple routine for most Ubuntu desktops and servers:

sudo apt update
sudo apt upgrade
sudo apt autoremove

That last command removes packages no longer needed. Old kernels often pile up. So do unused libraries. They sit there like cables in a drawer.

Use this routine weekly on desktops. Use it more often on internet-facing servers. Security fixes matter there.

If updates include a new kernel, reboot after the upgrade:

sudo reboot

Yes, rebooting is annoying. But not rebooting can leave your system running the old kernel. That means the fix is installed, but not active. Classic Linux mischief.

APT command cheat sheet

Here are the commands you will use most:

  • sudo apt update checks for updates.
  • sudo apt upgrade applies normal updates.
  • sudo apt full-upgrade allows package removals if needed.
  • sudo apt install name installs a package.
  • sudo apt remove name removes a package.
  • sudo apt autoremove cleans unused packages.
  • apt list --upgradable shows what can be upgraded.

full-upgrade sounds scary. It can be. It may remove packages to solve upgrade conflicts. Read the list before pressing Y. Do not mash Enter like you are closing a cookie popup.

What do-release-upgrade does

do-release-upgrade is not for normal package updates. It upgrades the whole Ubuntu release.

For example:

  • Ubuntu 22.04 LTS to Ubuntu 24.04 LTS
  • Ubuntu 23.10 to Ubuntu 24.04 LTS
  • Ubuntu 24.04 LTS to a later supported release

This is a bigger event. It changes system sources. It upgrades core packages. It may remove old software. It may disable third-party repositories. It can take 30 minutes. It can take longer on slow disks.

The catch is that one weird driver or ancient PPA can turn a smooth upgrade into a grumpy afternoon. Expect to spend time reading prompts.

Before using do-release-upgrade

Do not start a release upgrade cold. Prep first. Future you will be grateful.

  1. Back up your files. Use an external drive or a trusted backup tool.
  2. Update current packages. Start from a clean system.
  3. Remove junk. Old packages can cause mess.
  4. Check disk space. Keep several GB free.
  5. Disable risky PPAs. They can break the upgrade.

Run this first:

sudo apt update
sudo apt upgrade
sudo apt autoremove

Then reboot:

sudo reboot

After that, start the release upgrade:

sudo do-release-upgrade

If you are on an LTS release and no upgrade appears, try:

sudo do-release-upgrade -c

That checks for a new release without starting the full upgrade.

APT vs do-release-upgrade

Here is the plain difference.

Tool Best for How often Risk level
APT Security fixes and app updates Weekly or more Low to medium
do-release-upgrade Moving to a new Ubuntu version Every 6 months or 2 years Medium to high

Use APT when your Ubuntu version stays the same. Use do-release-upgrade when the version number changes.

APT keeps the house clean. do-release-upgrade remodels the house.

Server tips

On a server, be more careful. A broken desktop is irritating. A broken server is a phone call at 2 a.m.

Use a terminal multiplexer like tmux or screen before a release upgrade:

tmux
sudo do-release-upgrade

If your SSH session drops, the upgrade can keep running. That one trick can save your evening.

Also check services after updates:

systemctl --failed

If nothing failed, great. If something failed, inspect it:

systemctl status service-name

Common mistakes

  • Skipping backups. Bold choice. Bad idea.
  • Running release upgrades over shaky Wi-Fi. Please do not.
  • Ignoring prompts. Read before accepting config changes.
  • Keeping too many PPAs. They often lag behind new Ubuntu releases.
  • Never rebooting. Updates may need it.

A simple update schedule

For a home laptop, this works well:

  • Every week: run apt update and apt upgrade.
  • Every month: run apt autoremove.
  • Every year: check your Ubuntu support status.
  • Every 2 years on LTS: consider a release upgrade.

For servers, patch faster. Security updates should not wait for “when I feel like it.” That phrase has caused many bad Mondays.

Final rule of thumb

APT is for maintenance. Use it often. It keeps packages current and security fixes installed.

do-release-upgrade is for migration. Use it when you are ready for a new Ubuntu release. Back up first. Read prompts. Stay patient.

If you remember only one thing, remember this: APT updates your current Ubuntu. do-release-upgrade moves you to the next Ubuntu.