e

How to Control a Frozen Program

Experience Level: Beginner and up

Prerequisites: Following directions explicitly

Follow this tutorial with: “Explaining the LXTerminal and Bash,” “Using the LXTerminal and Bash” and “Beyond Bash Basics”

This is a stand-alone tutorial aside from our longer bash tutorials. When you have an unusable desktop because of a full-screen unresponsive program, you want the problem solved now – not five minutes from now.

The situation: a full-screen program is frozen on your desktop. You cannot access anything.

Background: Linux distributions have command-line consoles which you can access independently of your graphical desktop. Simply press and hold down the ctrl alt and f4 keys. When the screen blinks to a black background with white text, you see the first two lines:

Bodhi Linux followed by its installed version number

{your usernane} login:

Type in your user name, press Enter and you're greeted with your password login. Type in your password and press the Enter key again.

Let's say the unresponsive program is Midori. Not to pick on Midori, but it's the one preinstalled program on Bodhi Linux that would likely be in full-screen mode.

Type at the $ prompt: ps ux | grep midori

What will be returned to the console is output that looks like this:

{user name} 2522 2.2 1.4 188916 44428 ? SNsl 04:35 0:03 midori

The information you're looking for is in the second and the final fields: process number 2522 and the process midori

For new users, please note that this process number is only for illustration. Every time you run a program, it will have a unique process number.

Linux has a command called kill which sends a termination signal to a process. The form in which this takes at the command prompt is: kill 2522 (in this example).

This normally results with the offending process closing.

But sometimes a process needs…persuasion. And the kill command has leverage for that in the form of the option -9

So in the worst of all possible scenarios, the ultimate command prompt to close an unresponsive program is: kill -9 2522 (replacing 2522 with the actual process number, of course).

To verify this before logging out of the f4 console, the f7 key returns you to the graphical desktop by pressing the ctrl alt f7 keys.

When you see that the offending program is now gone, log one more time back into the console screen so you can exit the open console and then return to your graphical environment.

Do not leave the console screen active. While it is a small security risk in Bodhi Linux, no risk is always better than even a small risk.

Now with our fictional crisis over, you do not have to access the console only through the f4 key. You can also access different consoles with ctrl alt and either the f5 or f6 keys. The point is that you don't have only one option…you have several.

You could even run processes on several consoles at the same time even as you work away on your graphical desktop with its own (default) four virtual desktops. Now that's true multitasking!

How does the command sequence work?

ps is a shell command that reports a snapshot of the operating system's currently running processes.

ux is not a single command, but each letter – u and x – represent specific options which ps can use. In this case, u shows only processes executed by a valid user while x lists background processes.

The vertical symbol | is called a pipe. It's purpose is to send the output of the ps ux command not to the terminal, which is where the result would normally report, but sends (or pipes) the output to another shell command – in this case, grep.

The purpose of grep is simply to print lines to the terminal that match a pattern. In this case that pattern was the plain-text word midori, resulting in us finding the process number we needed and verified that the number belonged to the correct application.

At this moment someone will protest, “Wait! The command for this is ps aux | grep midori!”

Yes, you can use the a option, but the purpose of the a option is that it only reports the processes of other users that should be listed as well. If two people were sharing the same computer in a timesharing setup, the a option might be a valid inclusion. But for a single user on a machine, the same result is achieved by omitting the a option.

Most online and published book resources quote only the ps aux | grep {process} option, which is where most people get their information. That information is propagated endlessly throughout the internet as if it were inviolable. But the final authority is the ps manual page itself – all 920 lines of it, and that is the authority this use of the ux options are based upon.

For the absolutely curious, the tutorials “How to Read a Man page” and “How to Read an Info page” should provide good reading.

Meanwhile, kill is also a shell command with several options. Option -9 is simply the one which sends a non-ignorable signal to the offending process. If you are curious about the less drastic options, type man kill at your command prompt.


User Feedback

how_to_control_a_frozen_program
Did you find this article helpful?
Yes, right on the money!
 
100%(13)
Somewhat. Needs work.
0%(0)
Not really
0%(0)
Not at all.
0%(0)

If you would like to comment or make further suggestions, please leave a note on our Comments page (you will have to Create an Account if you haven't already).

 
how_to_control_a_frozen_program.txt · Last modified: 2011/04/28 13:10 by chipdoc · [Old revisions]


© Copyright Bodhi Linux 2012. All Rights Reserved - Hosted by vaultnetworks