sudo apt update to refresh the package list, then sudo apt upgrade to install the updates. On AlmaLinux or Rocky Linux, run sudo dnf upgrade. Afterwards, check whether a reboot is needed: Ubuntu and Debian create /var/run/reboot-required, and on AlmaLinux and Rocky sudo dnf needs-restarting -r tells you.
Before you start
- Connect with SSH as a user with sudo rights. If you are logged in as
root, leave outsudo. - On a production server, take a backup or snapshot first. Updates rarely break things, but a kernel or database update can.
- If you might lose SSH, have the VNC console ready.
How to update Ubuntu and Debian
1
Refresh the package list
2
See what will change (optional)
3
Install the updates
y and press Enter to confirm. Add -y to skip the question in scripts.4
Remove packages that are no longer needed
apt upgrade or apt full-upgrade?
apt upgrade never removes a package. If an update needs to remove or replace something, that package is “kept back”. apt full-upgrade (the same as apt-get dist-upgrade) also installs new dependencies and removes conflicting packages, which is what new kernels sometimes need.
y. full-upgrade updates within your current release; it does not move you to a new Ubuntu or Debian version. For that, see upgrade Ubuntu to a new release or upgrade Debian 12 to 13.
If a config file you changed also changed in the new package, apt asks what to do. The safe answer is the default, keep your currently-installed version (
N), then compare the files later.How to update AlmaLinux and Rocky Linux
1
Check for updates (optional)
2
Install all updates
dnf upgrade refreshes the repository metadata itself when it is out of date. Add --refresh to force a fresh download. Confirm with y.3
Remove unneeded packages
dnf always installs a new kernel next to the old one rather than replacing it, so you can boot the previous kernel if the new one causes a problem.
How to update a single package
- Ubuntu / Debian
- AlmaLinux / Rocky
How to check if a reboot is needed
Kernel,glibc and systemd updates only take full effect after a reboot.
- Ubuntu / Debian
- AlmaLinux / Rocky
*** System restart required ***, and the .pkgs file lists which packages asked for it. If it does not exist, no reboot is needed.How to check it worked
Run the update command again. When everything is current you see:- Ubuntu / Debian
- AlmaLinux / Rocky
Frequently asked questions
How often should I update my server?
Install security updates at least weekly, or turn on automatic security updates so they install daily.What does “The following packages have been kept back” mean?
The update needs to install or remove other packages, whichapt upgrade doesn’t do, or it is a phased update that Ubuntu is rolling out gradually. Run sudo apt full-upgrade to install the held packages, or wait a few days for phased updates.
Is apt-get different from apt?
apt is the friendlier command for people at the terminal. apt-get gives the same results with a stable output format, so use apt-get in scripts.
I get “Could not get lock /var/lib/dpkg/lock”. What now?
Another update is running, often the automatic one. Wait a few minutes and try again. See how to fix the dpkg lock error.Does yum still work on AlmaLinux and Rocky?
Yes. yum is a link to dnf, so sudo yum update runs the same update. New guides use dnf.
Related guides
VPS and dedicated server guides
Every server guide in one place.
Automatic security updates
unattended-upgrades and dnf-automatic.
Upgrade Ubuntu to a new release
Move from 22.04 to 24.04.
Fix apt and dnf repository errors
When updates fail.
Back up your VPS
Snapshot before big changes.
Checked against the official Red Hat Enterprise Linux 9 DNF documentation, the DNF needs-restarting plugin docs and the Ubuntu Server documentation on 4 November 2026; apt commands tested on Ubuntu 24.04 LTS. Commands can differ on other distributions or releases.
Need Extra Help?
If you encounter any issues, our support team is ready to assist:- Live Chat: Quick assistance via our website.
- Support Ticket: Open a Ticket
- Discord: Join our Community
- Email: support@freakhosting.com
Last Updated: November 2026