Eventually, you will encounter processes that either aren't working correctly or aren't working at all. Problems with processes usually manifest themselves as degraded system performance. For example, problematic processes may consume vast quantities of memory, causing your machine to
thrash[1], or they may consume lots of CPU resources, slowing down your system. Linux provides several diagnostic and control commands that allow you to manage processes. With these tools, you can identify troublesome processes, stop them, and control their behavior. Linux identifies processes by ID number. A
process ID (PID) is a unique, non-negative number that you use to identify and control processes. Commands that list processes do so by showing you each process's ID, along with other information such as program name and owner. Commands that manage processes often expect you to provide the process ID of the process you want to control.
View the table below to see a summarization of the available commands.
| Command name | Synopsis | Description | Example |
ps | Lists running processes | ps is the traditional UNIX tool for listing all active processes. ps provides a "snapshot" of the running processes. | ps -ef shows a list of all running processes with a great deal of information about each. |
top | Monitors running processes | top is a real-time process monitor. It allows you to see a constantly updated process listing and to interactively sort and manage processes. | top |
gtop | Monitors running processes | gtop is a graphical version of top that provides the same information as top, plus additional graphical representations of useddisk space and memory. | gtop |
kill | Terminates a process | kill allows you to send a signal most often the terminate signal, to a process. | kill 1928 kills the process with ID 1928. |
killall | Terminates processes by name | killall allows you to send a signal to one or more processes by name, not just process ID. | killall -KILL netscape kills all processes with the name "netscape". |
If you believe processes are causing your system to behave poorly, you'll need to identify and stop the culprits. The list below outlines the
general procedure:
- Run
top or gtop. Examine the %CPU and %MEM fields for a process that is significantly astray. Processes should take a reasonable amount of available CPU and memory, relative to other processes in the system.
- If just one process is at fault, note its PID and kill it:
kill -KILL pid. If several related processes are at fault, kill them
all by name killall -KILL name.
- If the X Window System is responding too slowly, type Control-Alt-F2 to obtain a text login prompt. Log in as root, fix the problem as
described above, and return to X Windows by typing Control-Alt-F7.
Note:
If the problem did not stem from a runaway process, it may be troubleshooting.sbhardware related.
Click the Start Simulation button below to practice troubleshooting some processes.
[1]Thrash: An activity which requires a great deal of paging, where a process spends more time paging than executing, causing a significant negative impact on a system's performance. Thrashing occurs when there is not enough RAM to handle all the required processes,
the solution is to move a process to disk, thereby leaving enough space for other processes to complete.