Restarting GNOME shell when it has frozen, without killing applications

Click For Summary
SUMMARY

To restart the GNOME shell on Ubuntu 20.04 without terminating running applications, users can switch to TTY3 using Ctrl + Alt + F3, log in, and execute the command sudo killall -1 gnome-shell. This method sends the SIGHUP signal, allowing the GNOME shell to restart while preserving open applications and unsaved changes. Users should verify the process ID (PID) of gnome-shell before and after executing the command to confirm a successful restart. This approach is preferable to using Alt + SysRq + REISUB, which reboots the system and closes all applications.

PREREQUISITES
  • Familiarity with Ubuntu 20.04 operating system
  • Basic knowledge of TTY command-line interface
  • Understanding of process management commands in Linux
  • Knowledge of signal types in Unix/Linux systems
NEXT STEPS
  • Research the differences between kill signals in Linux, specifically SIGHUP and SIGQUIT
  • Explore additional methods for managing GNOME shell stability
  • Learn about process monitoring tools in Linux to track application states
  • Investigate best practices for system maintenance to prevent GUI freezes
USEFUL FOR

This discussion is beneficial for Linux users, particularly those using Ubuntu 20.04, system administrators, and anyone seeking to enhance their experience with GNOME desktop environment stability and management.

Wrichik Basu
Science Advisor
Insights Author
Gold Member
Messages
2,180
Reaction score
2,721
Ubuntu has given me a far more stable working system compared to Windows and its buggy updates. But, once in a while, I do find GNOME becoming slow or even crashing. If I find that the GUI is becoming unresponsive, I promptly restart GNOME using Alt + F2rEnter This does the job most of the time, and GNOME works properly again.

But sometimes, the GUI becomes unresponsive such that the above does not work. The only option I have got is to use Alt + SysRq + REISUB. But this will reboot the system, and I will have to re-open all applications and lose unsaved work, if any.

Note that even when the shell is frozen, I can still go to a TTY using Ctrl + Alt + Fn.

Given that Linux has given its users the freedom to use different desktop environments, I guess that the underlying OS is not tightly "tied" with the desktop GUI, when compared to Windows. This rouses my question: is it possible to restart GNOME from a TTY command-line, without killing the running applications?

Upon searching the net, I found this question on AskUbuntu. The most upvoted answer states one should use killall -3 gnome-shell. Some comments say this works. I haven't tried it yet, but I am a bit sceptical: -3 corresponds to SIGQUIT, which, according to this, is the harshest of ignorable kill signals, and the process receiving the signal is expected to terminate itself as soon as possible without saving its state. So, the process is not expected to restart itself. The first comment under the above answer on AskUbuntu says that -3 should be replaced by -1 (SIGHUP), but that too is a kill signal and not a restart signal.

There are other answers to the question on AskUbuntu, and according to the comments, most don't (or occasionally) work.

Is there any other way that is known to work, and will not kill the running applications but restart GNOME shell?
 
Computer science news on Phys.org
It’s hard to know what will work in this case because the fault may not be in the gnome shell. The best you can do is be proactive about saving state periodically, rebooting when you’re done for the day, and backing up as needed.

one article I read talked about the benefits of rebooting that go beyond just getting things to work again.

https://www.pandasecurity.com/en/mediacenter/tips/turn-computer-off/
 
jedishrfu said:
rebooting when you’re done for the day
That's what I don't like to do. But Ubuntu does perform much better compared to Windows when I go without rebooting. My highest streak was 38 days, after which I had to shut down the laptop as I was boarding an aircraft.
 
I did some testing, and this is what works (at least for me, Ubuntu 20.04):
  1. Went to TTY3 by pressing Ctrl + Alt + F3
  2. Logged in as current user.
  3. Executed sudo killall -1 gnome-shell
  4. Return to GNOME by pressing Ctrl + Alt + F2
How I knew it worked:
  • None of the applications that were open, were closed. Unsaved changes still existed.
  • I noted down the process ID of gnome-shell before and after the above steps. It had changed.
Note that it might take some time for GNOME-shell to restart. It seems that it is restarted by the system itself. To check whether it was restarted, you can check the PID of gnome-shell before and after killing it:

20220104_152926-1.jpg


The pink arrows show the PID of GNOME before killing it. The kill command is highlighted by the red arrow. As indicated by the green arrows, just after killing, the PID is not returning anything, as GNOME had not started yet. Once a PID is returned (yellow arrows), it is safe to return to the GUI by pressing Ctrl + Alt + F2.
 
I am having a hell of a time finding a good all-in-one inkjet printer. I must have gone through 5 Canon, 2 HP, one Brother, one Epson and two 4 X 6 photo printers in the last 7 yrs. all have all sort of problems. I don't even know where to start anymore. my price range is $180-$400, not exactly the cheapest ones. Mainly it's for my wife which is not exactly good in tech. most of the problem is the printers kept changing the way it operate. Must be from auto update. I cannot turn off the...

Similar threads

Replies
10
Views
2K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 10 ·
Replies
10
Views
6K
  • · Replies 43 ·
2
Replies
43
Views
5K
  • · Replies 19 ·
Replies
19
Views
14K
  • · Replies 13 ·
Replies
13
Views
4K