DEV Community

miku86
miku86

Posted on

How to handle a simple freeze on your Linux system

Handling a simple Linux system freeze

Recently, I pressed some wrong key combo in Firefox and around ~80 tabs opened in Firefox... My music player played an endless loop.

Solution

First of all, I guess you are using a Desktop Environment, e.g. Gnome, KDE, Xfce.

Try to hit Cmd + Alt + F2.
This is a terminal which isn't linked to the current graphical session.
If you can't open it by pressing Cmd + Alt + F2,
try pressing Cmd + Alt + F3.

You will see a screen like this:

login

Now input your Username and Password.
If this works, you will see your user terminal, e.g. bash.
Now input htop and press Enter.

terminal

If you get something like command not found: htop, install htop, e.g.
sudo apt-get install htop or sudo pacman -S htop depending on the distro you're using.

htop will open up.

htop opens

At the bottom you can see some commands.
Press F6 to sort the list, on the left side a menu will open up,
where you should navigate to PERCENT_MEM and hit Enter.

sort list

Now the list is sorted by the processes, that use the most system memory.
Most of the time too much used memory leads to this kind of freeze.

Now navigate to the top of the list and choose the application, that probably causes the freeze, in my case /usr/lib/firefox/firefox is a good guess.
Now press F9 and another menu will pop up.
Choose 15 SIGTERM and hit Enter.

sigterm

If you're lucky, it will terminate the selected application.
If it doesn't work, choose 9 SIGKILL.

Sometimes you have to close multiple instances of the application,
you can also find them in the list.

You can go back to your Desktop Environment by pressing Cmd + Alt + F1.

Top comments (2)

Collapse
 
weakish profile image
Jang Rush

While I'm a loyal htop user, I do not think it is a good idea to install a new package when the system is almost freezing. I think it'd better to use top (preinstalled in most systems) and kill PID manually.

Collapse
 
miku86 profile image
miku86

You are right, if someone is familiar with the shortcuts, it's easier to use top. I like the menubar, so even beginners can use htop.