1

I've been testing various systems on my pc, and from time to time, my Linux laptop freezes.

On Windows, when this happens, you can press Ctrl+Alt+Del to bring up Task Manager and kill the process slowing the system down, no matter how badly locked up everything else was. I don't know how this was implemented; I guess it's like an emergency command, that forcibly reserves or steals some RAM from other processes.

Some of the questions asked here have similar solutions to that, like cold rebooting, restarting only the GUI or "kill mouse" that kills anything you click on, but I don't like 'em.

I want to make Ctrl+Alt+Del or any other hotkey, no matter what, bring up a "working" terminal with root privileges in seconds, so I have full control over my PC, no matter what programs are running or how much RAM is being used. It should be an emergency app that can be used any time with guarantee it will work. Is this even possible, and how should I do it?

Zanna
  • 72,312

2 Answers2

1

If your graphical session is frozen you can switch to a TTY, assuming default settings this can be done with Ctrl+Alt+F1 to F6. The TTYs run sessions separate from the “normal” graphical one, which by default is reachable with Ctrl+Alt+F7.

In a TTY you can use e.g. killall firefox to send SIGTERM to all running firefox processes, for more see How do I kill processes in Ubuntu?.


A different approach would be to change the niceness of your preferred terminal emulator, this way it is scheduled before “normal” processes of your system. To do so, just change the command used to start it (in a desktop shortcut or menu item for instance) from e.g.

yakuake

to:

/usr/bin/nice -n -20 /usr/bin/yakuake

I use the full paths by default just to be sure it runs properly, it may should also work without them. In case you're not sure, e.g. which yakuake shows you the full path.

For a running process you can use renice to change the niceness, e.g.:

sudo renice -20 $(pidof yakuake)
dessert
  • 40,956
0

Switch to a TTY

If your graphical session is frozen you can often switch to a TTY, assuming default settings this can be done with Ctrl+Alt+F1 to F6, as described in the answer by @dessert.

System Request (SysRq) sequence

Sometimes the system is so frozen, that the TTYs cannot be activated. Then you can use a System Request (SysRq) sequence. Often SysRq is invoked by the

Alt + PrintScreen keys, sometimes the Fn key is involved too (in laptops),

While pressing these keys you press the following keys slowly (maybe 1 second per key)

R E I S U B - reboot

R E I S U O - poweroff

See this link for more details,

en.wikipedia.org/wiki/Magic_SysRq_key

This is a way to poweroff or reboot linux systems gracefully, that often works to keep the file system healthy (in contrast to hard poweroff).

sudodus
  • 47,684