English: Linoxide
compiler: Linux China /geekpilinux.cn/article-2352-1.html
Linux in the top command displays processes running on the system. It is one of the most important tools for system administrators. It is widely used in load monitoring server. In this, we will explore the details of the top command. The top command is an interactive command. You can also run many commands when running the top. We will explore these commands.
(Translation: different releases of the top command in a variety of different details, if found to be not at the same time, please read the manual for your help and assistance in the command.)
A, Top command output
First, let's look at the output. The top command displays a lot of information systems. We need to understand the significance of different parts of output: the default runtime, top command displays the following output:
The first few lines show the level of generalization various system parameters, followed by the process and their property in the column.
Uptime and load averages 1.1 system
Top top command to display the uptime command output similar.
These fields show:
-
current time
-
The system has run out of time
-
The current number of logged-in users
-
The respective average load within the last 5, 10 and 15 minutes.
You may be used 'l' command to switch the display uptime.
1.2 Task
The second line shows the summary task or process. A process can be in different states. This shows the number of all processes. In addition, there are running, sleeping, stopped, the number of zombie process (zombie is a state of the process). These processes are summarized information may be displayed in 't' switching.
1.3 CPU status
The next row shows the state of the CPU. This shows the percentage of CPU time in different modes. These different CPU time, said:
-
us, user: Run (unadjusted priority) user process CPU time
-
sy, system: running kernel process CPU time
-
ni, niced: Run the user to adjust the priority of the process of CPU time
-
wa, IO wait: wait for IO completion of CPU time
-
hi: hardware interrupts the CPU time
-
si: software interrupt processing of CPU time
-
st: This virtual machine is stolen by the hypervisor CPU time (translation: if you are in vm under a hypervisor, hypervisor is actually consume part of the CPU processing time).
Can 't' command to switch the display.
1.4 Memory Usage
The next two lines of display memory usage, a bit like the 'free' command. The first line is the use of physical memory, virtual memory using the second line (swap space).
Physical memory appear as follows: all available memory, amount of memory used, free memory, buffer memory. Similarly: exchange section shows: all have been used, and the free buffer swap space.
Memory can display 'm' command to switch.
1.5 fields / columns
Attributes and state in the system laterally listed below, column process is shown. Different columns represent different attributes explained below.
On default, top displays them about the process:
PID
Unique identifier for the process ID, process
USER
The actual user name of the process owner.
PR
Scheduling priority of a process. Some value of this field is 'rt'. This means that these processes run in real-time mode.
NI
nice value of the process (priority). The smaller value means higher priority.
VIRT
Virtual memory used by the process.
RES
Resident memory size. Exchange non-resident memory size of physical memory used by the task.
SHR
SHR is the process of using shared memory.
S
This is the state of the process. It has the following different values:
-
D - uninterruptible sleep state.
-
R - operating mode
-
S - sleep state
-
T - tracked or stopped
-
Z - zombie state
%CPU
Ever since the last update to the CPU time used by the task now percentage.
%MEM
The percentage of available physical memory used by the process.
TIME+
After all the CPU time to start the task now used to the nearest hundredth of a second.
COMMAND
Run the command used by the process.
Many output by default not show, they can display a page fault process, effective group and group ID, and other additional information.
Second, the interactive command
We said before top is an interactive command. We have already met on a number of commands. Here we will explore more commands.
2.1 'h': Help
First, we can use the 'h' or '?' Interactive command to display the Help menu.
2.2 '' or '': refresh the display
After the top order to refresh the display in a particular default interval (3 seconds). To manually refresh the user can enter a space or carriage return.
2.3 'A': alternately switching the display mode
The command to switch between full-screen and the alternating mode. 4 is displayed in the alternate mode window (Annotation: focus on different fields, respectively):
-
Def (default field group)
-
Job (task field group)
-
MEM (Memory field group)
-
Usr (user field group)
There are four groups of fields a separate summary configurable area and its own configurable task area. 4 window, only one window is the current window. The name of the current window is displayed in the upper left. (Translation: only the current window will accept your keyboard-interactive command)
We can use the 'a' and 'w' to switch between four windows. 'A' moves to a rear window, 'w' Move to previous window. With 'g' command you can enter a number to select the current window.
2.4 'B': Trigger bold
Some important information is displayed in bold font. This command can be switched in bold.
2.5 'd' or 's': set the display refresh interval
When pressing 'd' or 's', you will be prompted to enter a value (in seconds), which will be set as the value of the refresh interval. If you enter here a 1, top refreshes per second.
2.6 'l', 't', 'm': load switching display, task information memory
This average load corresponding to the top of switching, the task / CPU and memory status information before display.
2.7 'f': field management
Used to select the fields you want to display. With a '*' mark is selected.
Up and down cursor keys to navigate in the field, the field can choose the left cursor key, a carriage return or right cursor key.
Press '<' moving to the left sorted field, '>' moves to the right.
2.8 'R': reverse ordering
Reverse switch / General sort.
2.9 'c': trigger command
Toggle display the full path and name of the program when the process starts.
2.10 'i': idle task
Switch the display idle task.
2.11 'V': Tree View
Switching tree view.
2.12 'Z': Color change
Press 'Z' to change a display command output color top screen to the user. 8 colors can be selected for the eight task areas.
The following shows a top view of a 4 color display.
2.13 'z': switching color display
Switching the color, i.e., a color display is opened or closed.
2.14 'x' or 'y'
Switching highlight information: 'x' will highlight the sort field (column); 'y' will highlight running processes (transverse). Depending on your display settings, you may need to output color to see them highlighted.
2.15 'u': a specific user process
Display a specific user process. You will be prompted to enter a user name. Blank will display all users.
2.16 'n' or '#': number of tasks
Sets the maximum number of tasks displayed
2.17 'k': End Task
A one of the top command of the most important commands. For transmitting signals to the task (usually the end of the task).
2.18 'r': reprioritizing
Re-set scheduling priority of a task.
Third, the command-line options
These command-line options and commands discussed above are mostly the same. The output of top command can be used to interoperate, but you can also run with no arguments top to set the effect you want.
3.1 -b: Batch mode
-b option to start the top command in batch mode. When you want to save the output file is very useful.
3.2 -c: Command / program name Trigger
As discussed above, the state command to, this option more than once to remember a program / command displays the display (whether to display the full path).
3.3 -d: set the delay interval
Set top display interval (in seconds). such as:
$ top -d 1
Top will start to refresh intervals of one second.
3.4 -i: to switch the display idle processes
This option is set on top of a command to remember the opposite of 'i' state.
3.5 -n: Set the number of iterations
With the -n option, you can set the number of iterations before the top exit.
$ top -n 3
Will exit after the refresh output three times.
3.6 -p: PID monitor specific
You can use the -p option to monitor the specified PID. PID is a value of 0 as its own PID top order.
3.7 -u or -U: user name or UID
Users can browse the specific process of these options. User name or UID may be specified in the options. -p, -u and -U options are mutually exclusive, but can only use one of these options. When you try to use a combination of these options, you'll get an error:
$ Top -u -p 28453 Raghu
top: conflicting process selections (U/p/u)