While working on a Linux systems like Ubuntu, Linux Mint, etc., through a graphical user interface (GUI) it may happen that some application will hang the GUI and freeze a system.
To unfreeze the system without rebooting a machine we can restart an X server (also known as X11, or just X) that is the default GUI environment on most Linux distributions.
This note shows how to restart the X server from a command line and unfreeze the system.
⚠ Warning: Restart of the X server will close all applications in your current session.
Restart X Server
Press Ctrl + Alt + T to start a terminal window.
If the GUI hangs and the terminal window is not opening, you can get to the text-only console on TTY1
by pressing Ctrl + Alt + F1.
Execute the following command to restart the X server:
$ sudo pkill X
The command above will restart the X server and drop you to the GUI login screen.