Introduction / Why This Is Needed
Regular Linux updates are a key practice for maintaining your system's security, stability, and currency. Updates patch vulnerabilities, fix bugs, and provide new features. This guide will help you safely and correctly update most popular Linux distributions, avoiding common pitfalls.
After completing it, you will have an up-to-date system with the latest fixes and improvements.
Requirements / Preparation
Before you begin, ensure the following conditions are met:
- Administrator privileges: You will need
sudoaccess or a root login. - Stable internet connection: Updates are downloaded from repositories.
- Free disk space: At least 1-2 GB for temporary files and updates.
- Backup (recommended):
- Back up important data in your home directory (
/home) and configuration files (/etc). - If possible, take a system snapshot via LVM, Btrfs, or your virtualization tool.
- Back up important data in your home directory (
- No interrupted operations: Complete any pending package installations (
dpkg,apt,yum, etc.) and close applications.
Step-by-Step Instructions
Step 1: Identify Your Distribution's Package Manager
Linux distributions use different package managers. Run one of the commands below to find out which one your system uses.
For Debian/Ubuntu-based distributions (apt):
which apt
If the command returns a path (e.g., /usr/bin/apt), you have apt.
For RHEL/CentOS/Fedora (yum/dnf):
which yum
or
which dnf
For Arch Linux (pacman):
which pacman
You can also check the /etc/os-release file:
cat /etc/os-release
Pay attention to the ID or NAME field.
💡 Tip: If you have multiple managers (e.g., both
aptandsnap), update your system via the distribution's primary manager (apt for Ubuntu/Debian).
Step 2: Update the Package Cache
The package cache contains information about available software versions. It must be updated so the package manager knows about the latest versions.
For apt (Debian, Ubuntu, Mint and derivatives):
sudo apt update
This command synchronizes your local package lists with the repositories.
For yum (CentOS 7, RHEL 7):
sudo yum check-update
The command checks for updates but does not install them.
For dnf (CentOS 8+, Fedora, RHEL 8+):
sudo dnf check-update
For pacman (Arch Linux, Manjaro):
sudo pacman -Sy
The -Sy flag updates the package database.
⚠️ Important: On Arch Linux, avoid using
sudo pacman -Syy(doubley) unless it's required to force a database update. This can cause synchronization issues.
Step 3: Install System Updates
After updating the cache, install the available updates.
For apt:
sudo apt upgrade
This command upgrades all packages without removing or installing new dependencies. For a full upgrade (including package removal or new dependencies), use:
sudo apt full-upgrade
Usually, upgrade is sufficient.
For yum:
sudo yum update
For dnf:
sudo dnf update
For pacman:
sudo pacman -Syu
The -Syu flag synchronizes, refreshes, and upgrades the entire system.
⚠️ Important: During the update, you may be prompted about configuration files (e.g., if you modified files in
/etc). Read messages carefully. If unsure, keep the local version (by default,aptordnfsaves a copy with extensions like.dpkg-oldor.rpmnew).
Step 4: Reboot the System (If Required)
A reboot is mandatory after a kernel or core system library (e.g., glibc, systemd) update. Otherwise, the system may run unstably.
Run:
sudo reboot
Or, if you are in a graphical environment, use the shutdown menu.
💡 Tip: To check if a reboot is needed on Ubuntu/Debian, use:
ls /var/run/reboot-requiredIf the file exists, a reboot is required. On other distributions, check if the kernel was updated:
uname -rand compare it with the installed kernel package version (e.g.,
rpm -qa | grep kernelfor yum/dnf).
Step 5: Verify the Update Result
After rebooting, ensure the update was successful.
- Check the distribution version:
lsb_release -a
orcat /etc/os-release - Check the kernel version:
uname -r - Ensure there are no pending updates (repeat steps 2 and 3):
sudo apt update && sudo apt list --upgradable
The list should be empty. - Check service status:
systemctl list-units --state=failed
There should be no services in afailedstate.
Result Verification
In short, the system is updated if:
- The command
sudo apt list --upgradable(or its equivalent for your manager) shows no packages. - The distribution version (
lsb_release -d) matches the expected one (e.g., after upgrading from Ubuntu 20.04 to 22.04). - All critical services (
systemctl) are running without errors. - A reboot is no longer required (the
/var/run/reboot-requiredfile is absent).
Potential Issues
"Not Enough Disk Space" Error
Symptom: The package manager reports insufficient space. Solution:
- Clean the package cache:
sudo apt clean # for apt sudo dnf clean all # for dnf sudo pacman -Sc # for pacman (caution: removes old versions) - Remove unnecessary packages:
sudo apt autoremove # for apt sudo dnf autoremove # for dnf - Free up space manually (old logs, temporary files).
Update Failure Due to Network Problems
Symptom: Connection drops, 404 Not Found, Temporary failure resolving errors.
Solution:
- Check your internet connection:
ping -c 3 8.8.8.8 - Switch to a different mirror (repository). For Ubuntu/Debian, edit
/etc/apt/sources.list; for other distributions, adjust your package manager's configuration. - Retry the update. Package managers (apt, dnf, pacman) usually resume downloads.
Package Conflicts or Dependencies
Symptom: Messages about "unmet dependencies" or "conflicts". Solution:
- For apt, try fixing dependencies:
Then runsudo apt --fix-broken installsudo apt upgradeagain. - For dnf/yum:
sudo dnf distro-sync # synchronizes packages with repositories - If the issue persists, manually identify the conflicting packages (the message will list them) and try removing/reinstalling them.
Configuration File Errors
Symptom: When updating a package, the manager asks whether to keep your current config.
Solution: If you didn't make important changes to the config, you can install the updated version (choose "Yes"). If the config was modified manually, keep the local version (choose "No" or preserve the old file). After updating, compare the files (diff /etc/package.conf /etc/package.conf.dpkg-old) and merge changes if necessary.