Linux Notice App

Fedora redo dnf


One of the most common mistakes when using Linux is deleting a seemingly innocent package and accidentally wiping out critical system dependencies along with it. For example, you might think you are just deleting a background package (like ultramarine-backgrounds-compat), only to realize that your SDDM (display manager) providing your graphical interface is gone, and your system drops to a black screen!

If you reinstalled the package using the install command but the system is still broken, don't worry. Thanks to DNF's excellent transaction history feature, we will restore everything to its original state with a single command.

Step 1: Viewing DNF Transaction History

DNF records every installation and removal process you perform. First, we need to find that transaction that broke the system. Type the following command in the terminal:

sudo dnf history list
Important Note: If you are on a distribution using DNF5 (the next-generation DNF), just typing dnf history like in older systems will give a "Missing command" error. You must append list to the end of the command.

Step 2: Finding the ID Number of the Faulty Transaction

In the output list, find the ID number on the far left of the transaction that broke the system (where you deleted the package). If the list is long, you can use this filter to see only the removal transactions:

sudo dnf history list | grep -i -E "remove|erase"

Once you find the transaction in this list, the number at the very beginning is the ID number of that transaction (For example: 70).

Step 3: Undoing the Transaction (The Magic Command)

Now for the most crucial part. We will use the "undo" command to bring back the package and all its deleted dependencies (SDDM, X11 components, etc.) in one go. Run the following command with the ID number you found:

sudo dnf history undo 70

(Don't forget to replace 70 with your own ID number.)

A small detail: If you tried to manually install the same package in the meantime, you might see a warning like "Transaction merge error" in the terminal; this is completely normal. DNF will skip what is already installed and install the missing vital parts. Confirm the transaction (Y) and wait for the installation to finish.

Step 4: Reboot

Once the installation is complete, all you need to do is restart your computer:

reboot

That's it! Your deleted graphical interface and login screen will continue to work right where they left off. Nothing is ever truly lost in Linux, as long as you know how to look at the DNF history!

No comments

Powered by Blogger.