How to upgrade Ubuntu Server to the next LTS with do-release-upgrade (and when it is urgent)
Every Ubuntu LTS has five years of standard security updates. After that, only paid Ubuntu Pro (ESM) updates continue. A release upgrade changes thousands of packages, so it is a planned job with a rollback, not something to run on a Friday.
Check your release and support dates
20.04 passed the end of standard support in April 2025. 22.04 reaches it in April 2027.
lsb_release -a ubuntu-security-statusTake a full snapshot
At the provider, a snapshot of the whole disk is the only real way back from a failed release upgrade.
Bring the current release fully up to date
The upgrade tool refuses to start with pending updates.
sudo apt-get update && sudo apt-get dist-upgrade -y sudo rebootDisable third-party repositories
PPAs and vendor repositories may not support the new release yet. The tool disables them, but check what you depend on.
grep -rhE '^deb ' /etc/apt/sources.list /etc/apt/sources.list.d/ | grep -v ubuntu.comRun it inside tmux
If your SSH connection drops, the upgrade must keep running.
sudo apt-get install -y tmux tmux new -s upgrade sudo do-release-upgradeCheck everything after the reboot
Services, sites, scheduled jobs and listening ports should match your list from before.
systemctl --failed sudo ss -ltnp cat /etc/os-release | head -n 3
Common mistakes
- Upgrading with no snapshot.
- Skipping from a release that is two LTS behind: go one step at a time.
- PHP, database and Node packages changing version silently with the new release: note them before.
How to undo it
Restore the snapshot. There is no supported way to downgrade a release in place.
Sources
Commands are for Debian and Ubuntu unless noted. Test on a copy first and keep a backup: you are responsible for changes on your own systems.