To update all the software on your Linux system, two
commands are enough: sudo apt update && sudo apt upgrade
(Debian/Ubuntu) or sudo dnf upgrade (RHEL/Fedora). This guide explains
why updates matter, how to apply them and when
a reboot is needed. It assumes you know how to
install and remove software
with your distribution's package manager.
What you will learn
- Why updates are essential for security
- The difference between
updateandupgrade - Apply updates with
aptanddnf - Know when a reboot is needed
- Check the available updates before applying them
Why should you update your system?
Updates fix three kinds of problems, and the risk of ignoring them is not the same for each:
| Kind of update | What it fixes | Risk if ignored |
|---|---|---|
| Security | Known vulnerabilities (CVE) | System exploitable remotely |
| Bug fix | Software malfunctions | Instability, crashes |
| Features | New capabilities | No immediate risk |
Security updates are the ones not to postpone. When a flaw is found in a piece of software, the distribution publishes a fix in its repositories. As long as you do not apply it, your system stays vulnerable.
What is the difference between update and upgrade?
On Debian/Ubuntu systems, update and upgrade are often
confused. They are two distinct steps, and only the second one changes
software:
| Command | What it does | Changes software? |
|---|---|---|
apt update | Downloads the list of available versions | No |
apt upgrade | Installs the new versions | Yes |
Think of apt update as browsing the catalogue of a shop, and
apt upgrade as buying the items. Running apt upgrade without having run
apt update is therefore like buying from an outdated catalogue.
This distinction does not exist everywhere. On RHEL and Fedora, there is no
command equivalent to apt update: DNF refreshes its metadata (the list of
available versions) when it has expired, 48 hours by default. dnf check-update,
dnf upgrade and dnf install perform this check, and the --refresh option
forces the refresh. dnf check-update lists the available updates; it is not an
equivalent of apt update. So you will not find this step in RHEL procedures,
and it is not an oversight.
How do you apply updates?
The three steps below always follow the same logic: look at what is waiting, apply it, then check that nothing is left.
-
Check the available updates:
Terminal window sudo apt updateThe last line of the output gives the number of packages to upgrade and reminds you of the command that displays their list. Tested on Ubuntu Server 26.04.1 (APT 3.2.1, English locale), on November 13, 2026:
Output (Ubuntu 26.04.1, end of sudo apt update) Reading package lists...Building dependency tree...Reading state information...1 package can be upgraded. Run 'apt list --upgradable' to see it.To see the details:
Terminal window apt list --upgradableOutput (Ubuntu 26.04.1) WARNING: apt does not have a stable CLI interface. Use with caution in scripts.Listing...distro-info/resolute-updates 1.15ubuntu0.1 amd64 [upgradable from: 1.15]The warning comes from
aptitself: its output is meant to be read, not parsed by a script. Each package takes one line, and the origin repository (hereresolute-updates) comes right after the name.Terminal window dnf check-updateDNF shows the list of packages with a newer version available. An exit code of 100 means that updates exist. Tested on AlmaLinux 10.2 (DNF 4.20.0), on November 13, 2026, with
dnf check-update; echo $?: the code is 100 and the output starts like this (the metadata download lines, then one package per line):Output (AlmaLinux 10.2, start) AlmaLinux 10 - AppStream 4.0 MB/s | 2.9 MB 00:00AlmaLinux 10 - BaseOS 12 MB/s | 56 MB 00:04AlmaLinux 10 - CRB 1.3 MB/s | 684 kB 00:00AlmaLinux 10 - Extras 32 kB/s | 13 kB 00:00almalinux-gpg-keys.x86_64 10.2-22.el10 baseosalmalinux-release.x86_64 10.2-22.el10 baseosalmalinux-repos.x86_64 10.2-22.el10 baseosThe three columns are the package name, the available version and the repository that provides it. On Fedora, DNF is at version 5: its output differs from this one, but the columns read the same way.
-
Apply the updates:
Terminal window sudo apt upgradeAPT 3 shows a one-line summary (
Summary:) that counts the packages upgraded, installed, removed and left aside, then asks for confirmation withContinue? [Y/n]. Read this summary before answering: a package to be removed deserves a look. Enter orYconfirms,ncancels. The prompt shown here is the one of an English locale; on a system set to French, its text may differ, but its meaning is the same.In the Ubuntu 26.04.1 example, the only pending package was not installed, and the output says so:
Output (Ubuntu 26.04.1, end of sudo apt upgrade) Calculating upgrade...Not upgrading yet due to phasing:distro-infoSummary:Upgrading: 0, Installing: 0, Removing: 0, Not Upgrading: 1Ubuntu rolls out some updates in stages (phasing): the package shows up in
apt list --upgradable, butapt upgradedefers it for this machine. This is not a failure: the update goes out to a growing number of machines, andapt upgradeinstalls it as soon as the rollout reaches yours. Security updates are never deferred this way.Terminal window sudo dnf upgradeDNF downloads and installs every available update after confirmation. The end of the output lists what was replaced (tested on AlmaLinux 10.2, on November 13, 2026):
Output (AlmaLinux 10.2, end of sudo dnf upgrade -y) Upgraded:almalinux-gpg-keys-10.2-22.el10.x86_64 almalinux-release-10.2-22.el10.x86_64almalinux-repos-10.2-22.el10.x86_64Complete! -
Check that everything is up to date:
Terminal window sudo apt update && apt list --upgradableOn an up-to-date system,
apt list --upgradableshows no package, only theListing...line and theaptwarning:Output (Debian 13, after apt update, system up to date, 2026-11-13) WARNING: apt does not have a stable CLI interface. Use with caution in scripts.Listing...A package still listed after
apt upgradeis not necessarily a failure: this is the case of the package deferred by the phasing seen in step 2.Terminal window dnf check-updateIf the system is up to date, the exit code is 0 and only the line about the age of the metadata appears (tested on AlmaLinux 10.2 after the update):
Output (AlmaLinux 10.2, system up to date) Last metadata expiration check: 0:00:03 ago on Fri 13 Nov 2026 07:17:58 PM UTC.
How do you apply security updates only?
Sometimes you want to apply only the security fixes, without updating features. The two families do not handle this the same way:
apt list --upgradable 2>/dev/null | grep -- '-security'The filter looks for the text -security in each line. On Ubuntu, a security
fix comes from a repository whose name ends in -security, and the command
returns one line per package. On Ubuntu 26.04.1 (November 13, 2026), the
only pending package came from resolute-updates: the command returned no line.
On Debian 13, no package was pending and the result was empty too. An empty
result means "no pending package from a security repository", not "the command
is broken". On Debian, look at the repository name shown in
apt list --upgradable: the filter only works if it ends in -security.
Another form circulates widely, apt upgrade -s | grep -i security, and
it is misleading for two reasons.
The first comes from the -s option, which simulates the upgrade: it displays
one Inst line then one Conf line for each package, plus a summary line. The
number of lines therefore does not count the security packages. When nothing is
to be installed, the simulation returns neither an Inst nor a Conf line.
The second is sneakier. This grep works on free text, not on the
origin repository: any package whose name contains
"security" passes the filter, whether it brings a security fix or not.
The form given above, which filters on -security, aims better, but it also keeps
any line that contains "-security", including a package whose name contains
that word. Some exist: debian-security-support, libapache2-mod-security2 or
python3-flask-security appear in the Debian 13 and Ubuntu 26.04 repositories
(apt-cache search --names-only -- -security lists them). Take this form as an
overview, not as a reliable count.
To install only these fixes, APT has no equivalent of DNF's
--security: you have to go through unattended-upgrades, whose
configuration only keeps the security source. The guide
apply security updates
shows this configuration.
sudo dnf upgrade --securityDNF has a native --security filter that only installs the
fixes classified as security updates. When no fix of this type is waiting, it
says so instead of silently doing nothing (tested on AlmaLinux 10.2, on
November 13, 2026, while 3 ordinary updates were available):
Last metadata expiration check: 0:07:11 ago on Fri 13 Nov 2026 07:10:48 PM UTC.No security updates needed, but 3 updates availableDependencies resolved.Nothing to do.Complete!When do you need to reboot?
Many updates apply without a reboot. But some cases require one:
| Update | Reboot needed? |
|---|---|
| Ordinary application (curl, vim...) | No |
| System library (libc, openssl) | Recommended (services to restart) |
| Linux kernel | Yes, to switch to the new kernel |
How do you know whether a reboot is needed?
Each family gives a direct answer, without having to guess from the list of updated packages:
If the /var/run/reboot-required file exists, a reboot is
needed:
cat /var/run/reboot-required 2>/dev/null || echo "No reboot needed"If the file exists, cat displays its content, a message that asks for the
reboot. Otherwise, the command displays the fallback sentence:
No reboot neededOn Debian, the absence of this file guarantees nothing: only the packages whose
install script asks for it create it. The Debian Policy describes it in
section 9.12. On Ubuntu, the update-notifier-common package takes care of it;
dpkg -l update-notifier-common tells you whether it is installed (it was not
on the Ubuntu 26.04.1 tested on November 13, 2026). Without it, the fallback
message proves only one thing: the file is absent.
The command that answers the question is dnf needs-restarting -r. Its
exit code carries the answer: 1 if a reboot is recommended, 0
otherwise. It is a DNF plugin, provided by the dnf-plugins-core package. This
package is present on some installations and absent from other images: the
AlmaLinux 10.2 cloud image (DNF 4.20.0, tested on November 13, 2026) does not
have it, and the subcommand is then missing.
sudo dnf needs-restarting -rNo such command: needs-restarting. Please use /bin/dnf --helpIt could be a DNF plugin command, try: "dnf install 'dnf-command(needs-restarting)'"DNF itself suggests sudo dnf install 'dnf-command(needs-restarting)', but
this advice fails on AlmaLinux 10.2:
No match for argument: dnf-command(needs-restarting)Error: Unable to find a match: dnf-command(needs-restarting)If the subcommand is missing on your system, install the package that brings the plugin, then run the command again:
sudo dnf install dnf-plugins-coresudo dnf needs-restarting -rNo core libraries or services have been updated since boot-up.Reboot should not be necessary.Code 0 and the sentence "Reboot should not be necessary" mean that no reboot
is needed. Watch the prefix: needs-restarting typed alone, without dnf in
front, is a different program, provided by the yum-utils package
(dnf provides '*/needs-restarting' shows it). It is absent by default: the
shell does not find the command, and bash then returns code 127.
To reboot:
sudo rebootOne last point, about method more than technique: on a production server, a reboot is planned in an announced maintenance window. Never restart a production machine without warning the team, even for an urgent fix: other services may depend on it without that showing anywhere on the machine itself.
Which update routine should you follow?
For a workstation or a test server, adopt this simple routine:
sudo apt update && sudo apt upgrade -yThe -y option answers "yes" to the confirmation automatically.
Use it only when you trust the updates
(workstation, lab).
sudo dnf upgrade -yThe following table gives an editorial opinion, not a rule set by APT, DNF or a distribution: adapt it to how the machine is used.
| Context | Recommended pace |
|---|---|
| Workstation, lab | Regularly, for example every week |
| Server exposed to the Internet | Security updates without waiting, preferably automatic |
| Production server | In a maintenance window |
Troubleshooting
An update usually fails for one of these reasons: another package manager is already running and holds the lock, a repository no longer answers or no longer exists, or a dependency conflict leaves the system half-way. Running the same command again fixes none of the three: find in the table the line that matches your message before insisting. For a dependency conflict that resists, the guide fix broken dependencies details the cases.
| Symptom | Likely cause | Fix |
|---|---|---|
Could not get lock /var/lib/dpkg/lock-frontend | Another manager is running | Wait, or check with ps aux | grep apt |
The repository no longer has a Release file | Repository obsolete or removed | Remove that repository from /etc/apt/sources.list.d/ |
Broken packages | Dependency conflict | sudo apt --fix-broken install |
Error: Failed to download metadata (DNF message) | Network problem or repository down | Check the connection, try again |
| Kernel updated without a reboot | Old kernel still running | Reboot with sudo reboot |
Key points
apt updaterefreshes the list;apt upgradeinstalls the new versions. Both are needed.dnf upgraderefreshes its metadata by itself when it has expired, then installs: there is no equivalent ofapt update.- Security updates come first: do not postpone them.
- A reboot is needed after a kernel update, and recommended after a system library update.
- Automate security updates on exposed servers, as the guide apply security updates explains.
- On a production server, update in a maintenance window.
Knowledge check
Check that the essentials of this guide stuck. The questions cover only what has just been explained here.
Knowledge check
Check what you have learned with this interactive quiz
How it works
- The timer starts when you click Start
- Multiple choice, true/false and short answer questions
- You can move between questions
- Detailed results are shown at the end
Starts the quiz and the timer
Review
(0/0)Result saved on this device. It will be sent to your account at the next sync. Sync now
Score by domain
A domain groups several guides and gets several questions, so its score is more reliable than a per-topic score, which often rests on a single question.
Summary
Strengths
No topic passed at 80% on at least two questions yet.
Weak areas
No topic below the pass mark.
Recommended next
Hints before you try again?
Continue the course: Clean and maintain your Linux system
A new full quiz with random questions
Work again only on the questions you missed