Troubleshooting Red Hat Linux   «Prev  Next»

Lesson 7 Troubleshooting processes
ObjectiveUse Linux tools to troubleshoot processes.

Troubleshooting Red Hat Linux Processes

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".

Fixing problematic processes

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:
  1. 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.
  2. 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.
  3. 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.
Text 1
1) Text 1
Text 2
2) Text 2
Text 3
3) Text 3
Text 4
4) Text 4
  1. You've discovered that a telnet process is not responding and you want to kill it. The ps -elf command displays a long, full list of all current processes. Because you're interested only in telnet processes, you'll use grep to display only the lines containing the string "telnet". Type the command |||(S1)ps -elf | grep telnet|||(S0) and press Enter to display all telnet processes.
  2. Prompt,
  3. ps -elf | grep telnet
  4. Please check your entry and try again.
  1. Here is the output of the command ps -elf | grep telnet. Because you wish to use the kill command to terminate the telnet process, note the PID (process ID number) associated with it. In this case, the PID is 1975, displayed in the fourth field. Type the command |||(S1)kill 1975|||(S0) and press Enter to send a TERM (terminate) signal to the telnet process
  2. Prompt,
  3. kill 1975
  4. Please check your entry and try again.
  1. The telnet process should be terminated, but let's display the current telnet processes to verify that the kill command worked. Type ps -elf | grep telnet again and press Enter.
  2. Prompt,
  3. ps -elf | grep telnet
  4. Please check your entry and try again.
  1. As you can see, the telnet program is no longer listed as a running process. The process has been successfully terminated. This completes the Simulation. Click the Exit button to return to the lesson.

Troubleshooting with ps and kill (Simulation transcript)

  1. You've discovered that a telnet process is not responding and you want to kill it. The ps -elf command displays a long, full list of all current processes. Because you're interested only in telnet processes, you'll use grep to display only the lines containing the string "telnet". Type the command ps -elf | grep telnet and press Enter to display all telnet processes.
  2. Here is the output of the command ps -elf | grep telnet. Because you wish to use the kill command to terminate the telnet process, note the PID (process ID number) associated with it. In this case, the PID is 1975, displayed in the fourth field. Type the command kill 1975 and press Enter to send a TERM (terminate) signal to the telnet process.
  3. The telnet process should be terminated, but let's display the current telnet processes to verify that the kill command worked. Type ps -elf | grep telnet again and press Enter.
  4. As you can see, the telnet program is no longer listed as a running process. The process has been successfully terminated. This completes the Simulation.
The next lesson concludes this module.
[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.