Ubuntu Pocket Guide and Reference

Page 110

Managing processes

One of the commonest command-line tasks is clearing-up programs that have crashed, something known as managing processes. On a technical level, Linux refers to currently running programs as processes.

NOTE Some programs start more than one process, so perhaps a better definition of a process is that it is all or part of a program, and not necessarily an entire program.

You can see a constantly updating list of processes by typing the top command in a terminal window (hitting Q will quit when you’re done).

As with files and folders, all processes are “owned” by a user. Only the individual who owns a process can terminate it, although the root user has the power to terminate any process.

The majority of processes listed in top are started at boot-up. These provide essential background services, such as the GUI. Such processes are usually owned by the root user. This protects them from interference by ordinary users. All processes are numbered. The number is known as the Process ID, or PID, and this is listed on the left of each entry in the top program list. To force a process to quit—known as killing the process—hit K and type the PID. You’ll be asked what signal you wish to send. Hitting Enter selects the default (15). This is fine in most cases.

You can also use the ps command to list processes at the command-line, and find-out process IDs. Normally the a, u and x command options are used with ps, and cause the command to return a full list of all processes complete with their names.

Additionally, the output is usually “piped” into the grep command to search for the program you’re interested in. I discuss piping in the Advanced Bash Techniques section later, but for now it’s enough to know that piping “sends” the output of one command into another.

Let’s look at an example. Although Firefox very rarely crashes, let’s say that you’ve visited a website that’s caused it to lock-up. All attempts to quit the program in the usual way no longer work. The following command will search the list of running processes and return the PID of Firefox:

ps aux|grep firefox

90 : Hands-on at the Command-Line


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.