Chapter 42. Gathering System Information

Before you learn how to configure your system, you should learn how to gather essential system information. For example, you should know how to find the amount of free memory, the amount of available hard drive space, how your hard drive is partitioned, and what processes are running. This chapter discusses how to retrieve this type of information from your Red Hat Enterprise Linux system using simple commands and a few simple programs.

42.1. System Processes

The ps ax command displays a list of current system processes, including processes owned by other users. To display the owner of the processes along with the processes use the command ps aux. This list is a static list; in other words, it is a snapshot of what is running when you invoked the command. If you want a constantly updated list of running processes, use top as described below.

The ps output can be long. To prevent it from scrolling off the screen, you can pipe it through less:

ps aux | less

You can use the ps command in combination with the grep command to see if a process is running. For example, to determine if Emacs is running, use the following command:

ps ax | grep emacs

The top command displays currently running processes and important information about them including their memory and CPU usage. The list is both real-time and interactive. An example of top's output is provided as follows:

 19:11:04  up  7:25,  9 users,  load average: 0.00, 0.05, 0.12
89 processes: 88 sleeping, 1 running, 0 zombie, 0 stopped
CPU states:  cpu    user    nice  system    irq  softirq  iowait    idle
           total    6.6%    0.0%    0.0%   0.0%     0.0%    0.0%  192.8%
           cpu00    6.7%    0.0%    0.1%   0.1%     0.0%    0.0%   92.8%
           cpu01    0.0%    0.0%    0.0%   0.0%     0.0%    0.0%  100.0%
Mem:  1028556k av,  241972k used,  786584k free,       0k shrd,   37712k buff
       162316k active,              18076k inactive
Swap: 1020116k av,       0k used, 1020116k free                   99340k cached
                                                                                
  PID USER     PRI  NI  SIZE  RSS SHARE STAT %CPU %MEM   TIME CPU COMMAND
 1899 root      15   0 17728  12M  4172 S     6.5  1.2 111:20   0 X
 6380 root      15   0  1144 1144   884 R     0.3  0.1   0:00   0 top
    1 root      15   0   488  488   432 S     0.0  0.0   0:05   1 init
    2 root      RT   0     0    0     0 SW    0.0  0.0   0:00   0 migration/0
    3 root      RT   0     0    0     0 SW    0.0  0.0   0:00   1 migration/1
    4 root      15   0     0    0     0 SW    0.0  0.0   0:00   0 keventd
    5 root      34  19     0    0     0 SWN   0.0  0.0   0:00   0 ksoftirqd/0
    6 root      34  19     0    0     0 SWN   0.0  0.0   0:00   1 ksoftirqd/1
    9 root      25   0     0    0     0 SW    0.0  0.0   0:00   0 bdflush
    7 root      15   0     0    0     0 SW    0.0  0.0   0:00   1 kswapd
    8 root      15   0     0    0     0 SW    0.0  0.0   0:00   1 kscand
   10 root      15   0     0    0     0 SW    0.0  0.0   0:01   1 kupdated
   11 root      25   0     0    0     0 SW    0.0  0.0   0:00   0 mdrecoveryd

To exit top, press the [q] key.

Useful interactive commands that you can use with top include the following:

CommandDescription
[Space]Immediately refresh the display
[h]Display a help screen
[k]Kill a process. You will be prompted for the process ID and the signal to send to it.
[n]Change the number of processes displayed. You will be prompted to enter the number.
[u]Sort by user.
[M]Sort by memory usage.
[P]Sort by CPU usage.

Table 42-1. Interactive top commands

TipTip
 

Application such as Mozilla and Nautilus are thread-aware — multiple threads are created to handle multiple users or multiple requests, and each thread is given a process ID. By default, ps and top only display the main (initial) thread. To view all threads, use the command ps -m or type [Shift]-[H] in top.

If you prefer a graphical interface for top, you can use the GNOME System Monitor. To start it from the desktop, select Main Menu Button (on the Panel) => System Tools => System Monitor or type gnome-system-monitor at a shell prompt from within the X Window System. Then select the Process Listing tab.

The GNOME System Monitor allows you to search for process in the list of running process as well as view all processes, your processes, or active processes.

To learn more about a process, select it and click the More Info button. Details about the process will be displayed at the bottom of the window.

To stop a process, select it and click End Process. This function is useful for processes that have stopped responding to user input.

To sort by the information in a specific column, click on the name of the column. The column that the information is sorted by appears in a darker gray color.

By default, the GNOME System Monitor does not display threads. To change this preferences, select Edit => Preferences, click the Process Listing tab, and select Show Threads. The preferences also allows you to configure the update interval, what type of information to display about each process by default, and the colors of the system monitor graphs.

Figure 42-1. GNOME System Monitor