Rescuing Unresponsive GUI on Linux
On Linux we have these virtual terminals (TTYs) built-in. They provide a way to bypass the whole graphical user interface and give you just a simple and reliable terminal.
To switch between different TTYs, you can use these shortcuts (that may change on older systems):
Ctrl + Alt + F1
- LockscreenCtrl + Alt + F2
- Desktop EnvironmentCtrl + Alt + F3
- TTY3Ctrl + Alt + F4
- TTY4Ctrl + Alt + F5
- TTY5Ctrl + Alt + F6
- TTY6
To get back to your desktop environment after testing, press Ctrl + Alt + F2
or run the command chvt 2
.
Unfreeze your Desktop Environment
Ever been gaming on Linux and then your whole system freezes? It sometimes happens to me when I'm testing some games on Heroic Games Launcher.
The solution is to go to one of the TTYs and kill the processes. I usually press Ctrl + Alt + F4
, put my username and password then run my alias unfreeze
command (which is kill -9 -1
).
To add an alias, go to your .bashrc
or .zshrc
and put this line somewhere at the end of the file:
alias unfreeze="kill -9 -1"
The kill -9 -1
command kills all processes that can be killed (including your game), which means you will go back to your lockscreen and will have a clean system. It feels like a quick reboot.
Another option is to install and use htop
to select and kill specific processes. This way when you go back to your desktop environment (Ctrl + Alt + F2
) other applications will be intact.