How to Upgrade Ubuntu From the Command Line: APT vs do-release-upgrade for Linux System Updates

How to Upgrade Ubuntu From the Command Line: APT vs do-release-upgrade for Linux System Updates

Use apt for normal updates, and use do-release-upgrade when you want to move to a newer Ubuntu version. That is the whole game. Ubuntu LTS releases get 5 years of standard security maintenance, so you do not need to jump versions every week like a caffeinated squirrel [source: Ubuntu].

TLDR: Use sudo apt update && sudo apt upgrade to update software on your current Ubuntu version. Use sudo do-release-upgrade to upgrade from one Ubuntu release to another, such as Ubuntu 22.04 to 24.04. For example, if a server has 187 package updates, APT handles that; if it needs a full release jump, use do-release-upgrade. Back up first, because fixing a broken upgrade at 1:17 AM is not character building.

APT vs do-release-upgrade: the simple version

Think of Ubuntu like a house.

  • APT changes the furniture, fixes the sink, and replaces the light bulbs.
  • do-release-upgrade moves you into a newer house.

APT updates packages inside your current Ubuntu release. It installs security fixes. It updates Firefox, OpenSSL, system libraries, drivers, and other packages.

do-release-upgrade changes the Ubuntu release itself. It edits software sources. It checks compatibility. It downloads a lot of packages. Then it performs the big swap.

Honestly, it feels like both commands should have names that explain this better. But here we are.

Use APT for regular system updates

This is the command you will use most often:

sudo apt update
sudo apt upgrade

The first command, apt update, refreshes the package list. It does not install anything. It just asks Ubuntu, “Hey, what new stuff is available?”

The second command, apt upgrade, installs safe upgrades for packages you already have.

You can also run both in one line:

sudo apt update && sudo apt upgrade

The && means the second command runs only if the first one works. Nice and tidy.

When should you use APT?

  • For weekly or daily security updates.
  • Before installing new software.
  • After adding a trusted software repository.
  • On servers that must stay patched.
  • On desktops where you want newer package fixes.

APT is the normal maintenance tool. It is boring. Boring is good. Boring means your system is not on fire.

Useful APT commands

Here are the commands worth knowing.

sudo apt update

Refreshes package information.

sudo apt upgrade

Installs regular upgrades.

sudo apt full-upgrade

Installs upgrades that may remove old packages if needed. This is stronger than apt upgrade.

sudo apt autoremove

Removes packages that are no longer needed. Old kernels often end up here.

apt list --upgradable

Shows packages waiting to be upgraded.

A clean update routine looks like this:

sudo apt update
apt list --upgradable
sudo apt upgrade
sudo apt autoremove

That is enough for most people, most of the time.

Use do-release-upgrade for a new Ubuntu version

Now for the bigger jump.

If you want to move from Ubuntu 22.04 LTS to 24.04 LTS, APT alone is not the right tool. You need:

sudo do-release-upgrade

This tool knows how to handle a release upgrade. It checks your current version. It checks package sources. It warns you about removed software. It asks questions. Sometimes too many questions. Expect to waste time answering prompts you thought were obvious.

Check your Ubuntu version first

Run:

lsb_release -a

Or:

cat /etc/os-release

You will see your current Ubuntu release. This matters. You do not want to guess before a full upgrade.

Update everything before the release upgrade

Before running do-release-upgrade, make your current system fully updated:

sudo apt update
sudo apt upgrade
sudo apt full-upgrade
sudo apt autoremove

Then reboot:

sudo reboot

Yes, reboot. I know. It is annoying. But stale services and old kernels can make upgrades weird.

How to run do-release-upgrade

After the reboot, run:

sudo do-release-upgrade

If Ubuntu says no new release is available, you may be on an LTS system waiting for the first point release. That is normal.

To check for a development release, there is this command:

sudo do-release-upgrade -d

But do not use it on production machines. The -d option can move you to a release that is not meant for calm, boring, paid work.

APT vs do-release-upgrade: quick comparison

Task Use APT Use do-release-upgrade
Install normal package updates Yes No
Apply security fixes Yes No
Move from 22.04 to 24.04 No Yes
Clean old packages Yes No
Change Ubuntu release files safely No Yes

Back up before you touch the big red button

Before a release upgrade, back up your data.

At minimum, save these:

  • /home for user files.
  • /etc for system config.
  • Database dumps, if you run MySQL, PostgreSQL, or MariaDB.
  • Web files, app files, and custom scripts.
  • A list of installed packages.

You can save a package list with:

dpkg --get-selections > packages.txt

If this is a cloud server, take a snapshot. If this is a laptop, plug it in. A dead battery during a release upgrade is comedy only if it happens to someone else.

Common problems and simple fixes

Problem: held packages

Check for held packages:

apt-mark showhold

If something appears, review it. A held package can block upgrades.

Problem: third-party repositories

Third-party repositories can break release upgrades. This includes PPAs and vendor repos.

The upgrade tool may disable them. That is normal. After the upgrade, re-enable only the ones that support your new Ubuntu version.

Problem: not enough disk space

Release upgrades need space. A lot of it.

Check space with:

df -h

Clean old packages with:

sudo apt autoremove
sudo apt clean

If /boot is full, old kernels are often the reason.

What should desktop users do?

If you use Ubuntu on a laptop or desktop, APT is great for regular updates. Use it often.

For release upgrades, you can use the graphical updater. But the command line gives clearer messages. It also feels less like waiting behind a curtain while your computer makes dramatic choices.

A safe desktop routine is:

sudo apt update
sudo apt upgrade
sudo apt autoremove

Then run:

sudo do-release-upgrade

Only do the second part when you are ready for a full release change.

What should server admins do?

Server admins should be more careful.

Patch with APT often. Test release upgrades on a staging server first. Check app versions. Check PHP, Python, Node.js, Nginx, Apache, database versions, and firewall rules.

Also use screen or tmux for remote upgrades:

sudo apt install tmux
tmux
sudo do-release-upgrade

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

The best upgrade rhythm

Here is a simple plan:

  • Daily or weekly: run APT updates.
  • Monthly: remove old packages.
  • Before big app installs: update with APT.
  • Every few years on LTS: use do-release-upgrade.
  • Before any release upgrade: back up and test.

So, APT is your regular mechanic. do-release-upgrade is the moving truck. Use the right one, and Ubuntu upgrades become much less scary.