Accidents can happen at any time on a computer system. Some small, some painfully large. One of such accidents can be removing or installing software in Linux and it causing havoc in your system. When you run a DNF remove command it does list all the packages and dependencies that are going to be removed and gives you the opportunity to abort. The problem can come into play if you get too complacent and just hit yes, or are just unaware of the impact of the removal of some of those packages to your system. I had such an incident while troubleshooting audio issues on my Fedora 23 system. The audio just wouldn’t play, and I thought about removing pulseaudio-7.1 from the system and seeing what would happen as one of my troubleshooting steps, basically to see if that package was causing my issues or not. For whatever reason dnf remove pulseaudio removes portions of the gnome-shell, enough of it to break the GUI interface completely. After the reboot and my system only coming up in the command line my mind flashed back and recalled the word gnome in the list and I figured that was what broke it.
I wasn’t too worried as I can get around in the command line just fine, but I still wanted my GUI for other reasons as this is a home workstation, not a server. I recalled a command from my Red Hat training that proved to be very useful in this situation. DNF History (yum history for CentOS and Red Hat). You will need to be logged on as root to perform this action of course. If it won’t fit on the screen just type the command dnf history | less then take note of the ID number on the left of the screen. The offending removal I had was ID 96. Then you just type DNF history undo 96 and the system will install all the packages that were removed earlier. I tried other things while I was there and messed it up a bit more, which is why you see in the screen shot individual gnome installs. I used the history to see what packages were removed and then did a batch install of them all. I then finished up with a systemctl set-default graphical.target and a reboot.
The system came up without incident and the Gnome GUI loaded as it did before I broke the system. The moral of the story is to first pay attention to what is being removed and to make sure that is REALLY okay. It is nice to know that the DNF history command is there however, and at some point you just may need to use it.