You've been working on your Linux system for a couple of hours and everything is okay. Then, you click on another link, open another web app, and everything freezes. If you spend any time running web applications on your older laptop, there's a chance that you might have run into this problem before.

What if there was a way to solve these situations quickly, without having to shut down your system? Well, the SysRq key combination is there to help you out. Let's take a closer look at how you can utilize this key combination to prevent thrashing on your computer.

Thrashing – Why Me?

The most likely scenario is that your machine has entered into a dreaded state known as thrashing. This is the worst-case scenario for a memory condition caused when you don't have enough memory. When the machine starts thrashing, the only thing you can do is try and kill the runaway process or, alternately, stop everything and recover later. And later when you do recover, you need to avoid starting so many applications at the same time.

Some would suggest buying a newer machine with more memory for running resource-hungry applications. But if you can't, there's a workaround to solve this problem as well.

Related: How much RAM do you really need?

Fix Thrashing Using the Magic SysRq Key Combination

So you still have your old machine for whatever reason but now you must deal with it. It's often not happy with modern websites, that have now adapted to client-side processing for the most part. It stalls. It freezes. It frustrates you.

You can't throw your computer across the room, but you can handle the situation by using a special keyboard combination. This is the most reliable way of shutting everything down short of holding down the power button.

  1. Press Ctrl + Alt + Fn keys on your keyboard simultaneously.
  2. Press the SysRq key with the other hand. If your keyboard doesn't have the SysRq label, press the Prtscn key.
  3. Release the Ctrl + Alt + Fn keys while still holding the SysRq key.
  4. Press the following keys in this sequence: R, E, I, S, U, B.
  5. Release all the keys.

After doing this wait for a few seconds and your machine will stop thrashing. The aforementioned key combination performed the following tasks on your system.

  • R: Switch the keyboard to Raw mode.
  • E: Send the SIGTERM signal to all the processes except init. This signal is responsible for the termination of the specified processes.
  • I: Send the SIGKILL signal to all the processes except init.
  • S: Sync all the filesystems that are currently mounted on the system.
  • U: Remount the filesystems in Read-only mode.
  • B: Reboot the system.

Fixing an Unresponsive Linux System

When low on memory, some specific processes can bottleneck the working of a computer. In situations like this, the SysRq key combination might come in handy. Alternatively, you can reboot your system to instantly kill the processes that might be causing the issue. But that's not a viable choice for all.

You can also monitor running processes on your Linux system using the ps command. The command will output information such as Process ID, the time allotted to the process by CPU, the current TTY shell, and more.