Rolling back a failed update depends on the package manager and the Linux distribution you are using. Here are some common methods for different systems:
For Debian/Ubuntu (using APT)
-
Using APT:
If an update fails, you can revert to the previous version of a package using:sudo apt install package-name=versionTo find the available versions of a package, use:
apt-cache showpkg package-name -
Using
dpkg:
If you have a.debfile of the previous version, you can install it directly:sudo dpkg -i /path/to/package.deb
For Red Hat/CentOS (using Yum or DNF)
-
Using DNF:
You can roll back to a previous version of a package with:sudo dnf downgrade package-nameTo see the history of transactions, use:
sudo dnf historyYou can then roll back to a specific transaction:
sudo dnf history undo transaction-id -
Using Yum:
Similar to DNF, you can downgrade a package:sudo yum downgrade package-name
General Considerations
- Backups: Always maintain regular backups of your system to restore it in case of critical failures.
- Snapshots: If you are using a filesystem that supports snapshots (like Btrfs or LVM), you can revert to a snapshot taken before the update.
- Logs: Check logs (like
/var/log/dpkg.logfor APT or/var/log/yum.logfor Yum) to identify what went wrong during the update.
These methods will help you roll back a failed update on your Linux system.
