1. Kill the X Server
Most “crashes” on Ubuntu are caused by an unresponsive X Server. If you’re not familiar, the X Server is the service that manages the Linux graphical environment. It’s a large complicated piece of software, and it tends to be the first thing to break down when something goes wrong.
Since X is just a service like any other running on the system, you should be able to stop and restart it. In order to do that, you’re going to need to get to a different console. There’s a fairly simple way to do that – press Ctrl + Alt + F3. On a Ubuntu system running GNOME, that will get you to an unused console. It should work with other desktop environments, too. If it doesn’t, try the different F keys. If absolutely nothing happens, try pressing Alt + SysRq + R first. In the event that none of that works, move on to a different method. Once you’re in the console, you can use it like you would any other terminal. Sign in and try to restart the X server. If you’re not using GNOME, replace gdm3 with “sddm” for KDE or “lightdm” for just about anything else.
That should restart X, but if it doesn’t, you can try looking up the process and killing it. In case that doesn’t work, try restarting the system.
2. SSH In
This is another solution for an unresponsive X server. Sometimes accessing the console is too much of a pain, or it’s simply not working. In that case you might still be able to get into the system over your network with SSH. If your Ubuntu install isn’t running SSH, it’s simple enough to install.
You can jump onto another computer and use SSH to access Ubuntu. Use your username and the IP address of your Ubuntu machine.
Once you’re in, you can use the terminal like you normally would. Again, you can try to restart X. If that doesn’t work, try killing the process or restarting the machine.
3. Alt + SysRq + REISUB
It’s not always the X server that locks up a Linux system. It could be a genuine crash of the entire system. Thankfully, the Linux kernel has built-in tools to allow you low-level control of the system in the event everything else goes wrong. These commands are accessible by pressing the combination of Alt and SysRq on your keyboard. That combination of keys tells the Linux kernel to stop listening to just about everything else and pay attention to the user’s input. To completely bypass the crash and reboot the system, press Alt + SysRq, then enter the following keys in order R – E – I – S – U – B . (This is the opposite of the word “BUSIER.”) That combination of keys will steal keyboard control away from X, terminate all processes running on the machine, sync up the data on your hard drives, unmount the drives, and reboot the system. Essentially, it manually simulates the shutdown process. When your system boots up again, everything should be normal.
4. Chroot from Live CD
What happens if it’s not normal? What if something really bad happened, and the system broke and won’t boot? There’s something that you can try in that situation, too. You’ll need a Ubuntu live CD (it can be a USB), so if you don’t already have one, it’s a good idea to have one on hand anyway. Boot your computer into the live CD. Then, from within the live CD, you’ll need to create a few directories to work from. Mount your computer’s partitions in those directories. Check your actual partition labels. Mount a couple of system directories in the recovery directory structure to make sure everything works properly.
Finally, use chroot to change your root directory to your crashed Ubuntu system’s root. This will allow you to actually use the crashed system. Now that you’re in the system, you can try to debug it and find exactly what’s broken. Seeing as you couldn’t boot, the GRUB bootloader would be a good place to start looking. If you have a broken upgrade, you can also run Apt from here, and it will upgrade your system or repair your broken upgrade. Again, there isn’t going to be one universal solution from here, but at least you can access your system to figure it out. In the rare event that your system actually is broken beyond repair, use the live CD to back up your files from your /home directory to an external or networked hard drive. That said, that method or one of the others should be able to get you back to a functional Ubuntu system. This article was first published in September 2008 and was updated in May 2018.