What to do if linux hangs

Help, my Linux Desktop hangs!

This might not happen often nowadays but sometimes the desktop gets frozen and you have no idea how to unfreeze it. It is especially frustrating when you have unsaved work and you see no other option than to restart losing on things you were working on.

Depending on what software runs with Linux there are different things you can do.

What about Windows?

Of course there is the task manager where you can dive in. When a program does something weird, just kill it. I usually right-click on the taskbar and select „Task Manager“. If that does not work just press CTRL+ALT+DEL and select „Task Manager“ from there. If that does not work anymore, so to say you have no access to these options, you might have to restart the system. I don’t know about any other method on Windows. Maybe you have an idea.

Now let’s get to Linux, there you can do a lot more.

Different strategies

First of all, if your system suffers often under such problems and you bother with it, you might want to try a different Distro or maybe even another operating system. Remember, there exist more stable distros and more experimentational ones. Of course Linux is not for everyone and not the only option.

Also software developers should be accustomed to the fact that operating systems might eventually break, because some performed operations yet to become stable in the being developed code have still a way there. If you have unprotected access somewhere to the hardware because you require it to be so, you should not be surprised if the operating system doesn’t take it that nicely.

Knowing different methods

I consider it useful to have a mix of different methods you can try out for some more confident usage. The goal of this article is to show what different things you can do under Linux when your system does not react anymore.

Know your Desktop Environment

Personally I like to have a quick access to something like a Process Manager, where I am able to kill processes that might become problematic.

If you use Ubuntu, Linux Mint or something with the Gnome Desktop it is called gnome-system-monitor what gives the control over the processes being executed. I also recommend having a watch over the system resources always visible so you can react fast enough by opening the system monitor and killing the process whenever required. Under Gnome I use this extension:

Читайте также:  Что значит символ в linux

By opening the menu and just clicking on System Monitor… I get it opened. Also this extension has a lot of customization options, highly recommended.

For KDE Plasma there exist similar tools and the KSystemGuard does a good job there. You can also use it on Gnome but it is not recommended. It really belongs to KDE Plasma.

No reaction if I click on something

That situation might many people lead to give up, but there is a lot more you can try out. If only Gnome shell is frozen maybe other programs still run fine. There is a keystroke, try ALT+F2 and put the letter ‚r‘ into the box displayed. This restarts the gnome shell entirely, but the running programs remain open. It brings the system back into a more stable state.

Nothing in the Desktop Environment works anymore

If you cannot click on elements and the keystroke with ALT+F2 leads to no reaction, then you might need to get deeper. Linux is not all about desktop environments. The programs might be running in the background and if only a small component is hindering the process we only might have to kill it and go back.

Try to change the TTY (Terminal TYpe). That means, change to a console where you can type commands. Don’t worry, there not much typing to be done. On most systems you have the graphical interface (X or maybe Wayland) opened which is where you are now, mostly TTY2 (or TTY7 on older systems). Let’s change to TTY3 with CTRL+ALT+F3. You might be greeted with Login. Type in your username and password so you get a prompt.

If you have not done already, install htop. Under Ubuntu-like Systems (also Mint) you do this with

Let it install if not done already and start that process manager with just typing

and you will see something like a console based windows which can be controlled using the arrows keys and the functional keys (F1-F10) for commands. Above the list you see how much load you have on your cores and how much memory is used in total.

With F9 you can kill the currently selected process. The processes at top of the list are those which take most of the CPU. You can sort the list differently or even show process trees. High CPU is a good indication where to look at, if your system behaves funny. Selecting the suspicious process (yes, it can even be Firefox if you have a cryptomining site with strange JS code running) and pressing F9 will open a list of signal to send. If you want to kill the process radically, you can choose 9 – SIGKILL and the kernel will kick this process out of the ecosystem.

Читайте также:  Astra linux usb носители

Now if you see that the CPU or memory consumption lowered and you think it might have been the process making the desktop get frozen, you might want to switch back to the graphical interface. You can do that by just pressing CTRL+ALT+F2 (or CTRL+ALT+F7 on older systems).

If you were right the Desktop might be responsive again. If that did not help you can go back pressing (CTRL+ALT+F3) and will see that the htop instance still running and usable. Just continue looking what it could be and kill more problematic processes.

If everything is back to normal, you should consider that the TTY3 is a second session you opened. By quitting htop (Pressing F10) and typing exit as command the console session gets closed. I like to forget that session afterwards and when the PC is being shutdown later on you might get a message asking you if the other session should be closed also. Nothing to worry about.

No Reaction even after Switching TTY

I have no idea what to do then. Sometimes SSH can help if the kernel is active using another computer in the same network but if you are not even able to login, that might not work. In such cases you might have to really reboot the machine even cold hearted turning it off.

I do not remember having such situation under Linux but I know it can happen. I had kernel panics with hardware which was defective but only when booting. Still though such freezes can happen when the system is already running and at bad state somehow.

What else?

Here is a nice discussion and more hints by other developers:

Conclusion

If I debug into certain breakpoints in some application code which uses Qt libraries using the QtCreator as debugger frontend, I sometimes manage to freeze my desktop. But everything else really is running. The problem is mostly that sometimes Qt lib tries to pull all my events, so I cannot do a thing anymore using the Desktop Environment. This a situation where changing the TTY and killing the GDB instace stabilizes the Desktop back again. QtCreator gets a bit weird, but after some seconds it finds out GDB was killed and everything is fine again. You can continue working normally… 🙂

Читайте также:  Linux узнать число ядер процессора

There is no perfect system but it is incredible what CPU power houses we have today. I hope these small hints help you having your system under control even in those infamous situations.

Источник

What to do when your Linux hangs?

Linux, despite “popular belief”, does crash (hangs or jams). Sometimes it is one or two applications per deadlock and everything can be resolved with a kill -9 to the application hanging from the terminal, this only if it is possible to change the terminal with ctrl + alt + 1, or ctrl + alt + 2, or or doing a Ctrl + Alt + Backspace (if you have it enabled) to restart the X; But if after they have already tried all of the above and still nothing could be achieved, many of us or those of us who do not know this, what we do is press our power button to turn it off and this causes our disk to start to fail Lasted.

What should we do when Hangs?

Magic SysRq key is a key combination in the Linux kernel that allows the user to execute various low-level commands regardless of the system state. This means that, even if your computer hangs on all sides and seems not to respond, this set of keys will give you a better solution than the “power off” one, allowing you, among other things, to synchronize the hard drives so that you do not lose everything. what you have been doing.

How does it work? Easy. The standard combination is as follows: ALT + Sysrq (print screen) + command, where Sysrq is the key that appears on current keyboards as Print screen and Sys Request (System Request). One of the most famous combinations is REISUB:
Alt + SysRq+:

R: Puts the keyboard in XLATE mode (ASCII mode, NOT UNICODE)

E: Terminates (term) all processes (except init).

I: Forces the “cascaded” processes to end, so that the files in use can be written to disk.

S: You empty the disk caches, finalizing all disk writes.

U: Reassemble all filesystems as read-only, so that nothing can be accidentally written just before the reset.

B: Reset the system.

If, for whatever reason, the Sysrq key doesn’t work for you, write the following: echo command> / proc / sysrq-trigger

Where command is any letter you want Sysrq to make.

Источник

Оцените статью
Adblock
detector