Sub topic 7
Bring the system up to date
Prerequisites and the update model
Assume you have logged in with an account that can use sudo, the command that runs one command with administrative privileges. You also need a working network connection and a configured package repository.
A package manager is software that downloads, installs, upgrades, and removes software packages. Before upgrading, refresh its package metadata. Metadata is the local list of available packages and their versions. Refreshing metadata does not install updates.
| Distribution family | Refresh metadata | Install available updates |
|---|---|---|
| Debian and Ubuntu | `sudo apt update` | `sudo apt full-upgrade` |
| RHEL, Rocky, Alma, and Fedora | Included with `dnf upgrade --refresh` | `sudo dnf upgrade --refresh` |
The difference between refreshing metadata and installing packages matters. A server can know that updates exist without actually installing them.
Apply pending updates
First identify the distribution and release:
cat /etc/os-releaseOn Debian or Ubuntu, refresh metadata and apply all available upgrades:
sudo apt update
sudo apt full-upgradefull-upgrade can install or remove packages when needed to complete a dependency change. A dependency is another package required by software. Review the proposed changes before confirming. Do not accept a removal that would delete a service you still need.
On a RHEL-family system, use:
sudo dnf upgrade --refreshThe --refresh option forces a fresh metadata check. This is useful on a new installation because the package lists may have been created before the server received network access.
Reboot when the running kernel changed
A kernel is the part of Linux that controls hardware and provides core services to applications. Updating the kernel installs a new kernel package, but the running system continues using the old kernel until rebooted.
Check whether the installed kernel differs from the running kernel:
uname -rOn Debian and Ubuntu, this command can indicate whether a reboot is recommended:
test -f /var/run/reboot-required && echo "Reboot required" || echo "No reboot flag"Plan a reboot when the update includes a kernel, core libraries, or other components that cannot be replaced safely while running. In a remote session, make sure you know how to reconnect before rebooting.
Verify the result
After the transaction completes, check for failed services and confirm the system is still reachable:
systemctl --failed
uptimeAn empty failed-unit list is expected. Record the update date and any reboot in your server maintenance notes.
Exercise
Why must you run apt update before installing updates on Debian or Ubuntu?
Show answer
It refreshes the local package metadata, so the package manager knows which versions are currently available from the configured repositories.