While Linux has a reputation for being stable, able to keep chugging along for years, there are times when the desktop will just freeze and stop responding to input. One of the most common fixes for a frozen desktop is to restart the PC. An easier way is to just restart the desktop.
Let’s see how to do this on five of the most popular desktop environments in Linux: Gnome, KDE, XFCE, LXQt and MATE. We are using Ubuntu (Kubuntu/Xubuntu/Lubuntu/Ubuntu MATE) for this illustration.
Also read: How to Hide the Top Bar and Side Panel in Ubuntu
Restart Gnome in Ubuntu
If your desktop can still respond to your keyboard, press Alt + F2, type the single letter r on the pop-up window, and press Enter.
This will restart your desktop environment without much fuss. If your desktop doesn’t respond to your input, though, you will have to take more drastic measures.
Press Ctrl + Alt + F3 to access the first terminal outside of your desktop environment.
Enter the following command to restart the Gnome desktop environment:
gnome-shell --replace
Press Ctrl + Alt + F2 to move back to the desktop and, if everything goes according to plan, a refreshed version of your desktop will be waiting for you.
If that doesn’t work, you can try restarting the display manager. Since the display manager is the “base” on which the desktop environment runs, by restarting it, you also end up reloading the desktop environment. To do that, go back to the terminal and enter the following:
sudo systemctl restart gdm
Note that this fully reloads the desktop environment, so you will have to log in again from scratch.
Also read: How to Fix the “No Installation Candidate” Problem in Ubuntu
Restart KDE in Kubuntu
Restarting the KDE desktop environment follows the same approach as Gnome, but there are small differences in the individual steps you have to take.
In Kubuntu, the first available terminal outside your desktop environment is TTY3, so you will have to use the Ctrl + Alt + F3 combination to get there.
In the latest versions of KDE, the proper way to restart the desktop from the terminal is:
kquitapp5 plasmashell && kstart5 plasmashell
If that doesn’t work, you can also try:
pkill -ABRT plasmashell
If that fails as well, it will be worth a try to restart the display manager itself as a last option before rebooting your whole PC. Try it with:
pkill -ABRT kwin_x11
Note, though, that this forced restart of the desktop environment may also lead to the appearance of some error messages.
Also read: How to Enable Wake-on-LAN in Ubuntu
Restart XFCE in Xubuntu
With XFCE being a much simpler desktop environment than Gnome and KDE, restarting it is also easier.
The primary desktop element of XFCE – and the most probable to freeze – is its panel. If your desktop is still somewhat responsive, restart it by firing up a terminal with the Ctrl + Alt + T combination and typing:
killall xfce4-panel
This command will “kill” the panel. To reload it, enter:
xfce4-panel & disown
To restart the whole window manager, move to the first available terminal outside of your desktop. On the Xubuntu installation, it was the first one, accessible with the Ctrl + Alt + F2 combination. There, try the official approach:
xfwm4 --replace
If that doesn’t work, try the more forceful approach:
killall xfwm4 & xfwm4 & disown
Hopefully, your desktop will be back up and running, waiting for you.
Also read: How to Set Up WordPress Using Docker in Ubuntu
Restart LXQt in Lubuntu
LXQt is a simple desktop environment that aims to work with small, lightweight machines. Similar to XFCE, reloading this desktop environment mostly consists of restarting its panel.
To start, access a terminal emulator inside the environment. Create a .desktop file that can launch a terminal emulator by pressing right-click on the Desktop and selecting “Create Launcher.”
This will display a prompt where you can provide the details for your shortcut. To create a Terminal launcher, write /bin/bash
in the “Command” field and toggle the “Terminal” option.
Click this shortcut to open a new Terminal, then run the following commands to restart the LXQt panel:
qdbus org.lxqt.session /LXQtSession stopModule lxqt-panel.desktop qdbus org.lxqt.session /LXQtSession startModule lxqt-panel.desktop
On the other hand, it is also possible to reload the entire LXQt desktop. This is handy if you cannot access any of the environment’s features through the graphical interface.
Press Ctrl + Alt + F3 to drop to a TTY shell, then run the following command to fully restart LXQt:
sudo systemctl restart sddm
Also read: How to Fix Windows MBR from Ubuntu
Restart MATE in Ubuntu MATE
MATE is a flexible desktop environment that aims to continue the GNOME2 design language. To restart this environment, open a Terminal window by pressing Ctrl + Alt + T.
Run the following commands to fully reload MATE:
mate-settings-daemon --replace mate-panel --replace marco --no-composite --replace
It can be useful to fully reset the MATE desktop in instances where you want to undo a system configuration that can potentially break your system.
Similar to other desktop environments, do this by dropping to a TTY, then run the following command:
mate-panel --reset
Also read: Top 7 Debian-Based Distros to Try If You Want an Ubuntu Alternative
Restart the Xorg Server
Restarting the entire Xorg server instead of your specific desktop environment is useful if you want to restart your display and are either running without a display manager or using a window manager such as bspwm.
To restart Xorg, you need to drop to your TTY. Press Ctrl + Alt + F3.
Send a SIGTERM signal to the main Xorg process by running the following command:
pkill X
Xorg will immediately stop and restart itself in your machine. Go back to your graphical interface by pressing Ctrl + Alt + F1.
Also read: How to Fix the Ubuntu Login Loop
Frequently Asked Questions
Does a desktop restart corrupt any files that I am working on?
Luckily, no. The standard Linux filesystem works in a way that it can tolerate abrupt system changes, as most files in your machine can preserve some data about their state before the restart. While data corruption is less likely in Linux, it is still possible to lose data that only exists in your machine’s memory. You need to make sure that you have saved everything you’re currently doing to disk before attempting any desktop restart.
Is it possible to use a different TTY to restart a desktop?
Yes! By default, the Linux kernel supports up to six virtual terminal sessions at the same time, which is useful if you want to run a process while trying to restart your GUI environment. To access these extra TTYs, press Ctrl + Alt followed by any key between F2 and F8.
Is it still possible to restart a frozen system if you cannot use the TTY?
Yes! One option is to use Linux’s Magic SysRq Keycodes. These are hidden key combinations that allow you to access some of the kernel’s debugging tools. To restart your system by force, press Alt + SysRq + R, then Alt + SysRq + B. Doing this will switch your kernel’s keyboard driver to “Raw,” then trigger a “Force Reboot” instruction.
Image credit: Simone Pellegrini via Unsplash. All screenshots by Ramces Red.
Our latest tutorials delivered straight to your inbox