In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to use the Top command in Linux, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand.
TOP is a dynamic display process, that is, the user can press the key to constantly refresh the current state. If the command is executed at the foreground, it will monopolize the foreground until the user terminates the program. More accurately, the top command provides real-time monitoring of the status of the system processor. It will display a list of CPU's most sensitive tasks in the system. This command can be used by CPU. Memory usage and execution time sort tasks; and many of the features of this command can be set through interactive commands or in personal customization files.
Top-12:38:33 up 50 days, 23:15, 7 users, load average: 60.58,61.1461.22
Tasks: 203 total, 60 running, 139 sleeping, 4 stopped, 0 zombie
Cpu (s): 27.0%us, 73.0%sy, 0.0%ni, 0.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 1939780k total, 1375280k used, 564500k free, 109680k buffers
Swap: 4401800k total, 497456k used, 3904344k free, 848712k cached
PID USER PR NI VIRT RES SHR S CPU MEM TIME+ COMMAND
4338 oracle 25 0 627m 209m 207m R 0 11.0 297:14.76 oracle
4267 oracle 25 0 626m 144m 143m R 6 7.6 89:16.62 oracle
3458 oracle 25 0 672m 133m 124m R 0 7.1 1283:08 oracle
3478 oracle 25 0 672m 124m 115m R 0 6.6 1272:30 oracle
3395 oracle 25 0 672m 122m 113m R 0 6.5 1270:03 oracle
3480 oracle 25 0 672m 122m 109m R 8 6.4 1274:13 oracle
3399 oracle 25 0 672m 121m 110m R 0 6.4 1279:37 oracle
4261 oracle 25 0 634m 100m 99m R 0 5.3 86:13.90 oracle
25737 oracle 25 0 632m 81m 74m R 0 4.3 272:35.42 oracle
7072 oracle 25 0 626m 72m 71m R 0 3.8 6:35.68 oracle
16073 oracle 25 0 630m 68m 63m R 8 3.6 175:20.36 oracle
16140 oracle 25 0 630m 66m 60m R 0 3.5 175:13.42 oracle
16122 oracle 25 0 630m 66m 60m R 0 3.5 176:47.73 oracle
786 oracle 25 0 627m 63m 63m R 0 3.4 1:54.93 oracle
4271 oracle 25 0 627m 59m 58m R 8 3.1 86:09.64 oracle
4273 oracle 25 0 627m 57m 56m R 8 3.0 84:38.20 oracle
22670 oracle 25 0 626m 50m 49m R 0 2.7 84:55.82 oracle
one。 Statistics of the first five lines of TOP
The first five lines in the statistics area are the statistics of the system as a whole.
1. The first line is the task queue information
Same as the execution result of the uptime command:
[root@localhost ~] # uptime
13:22:30 up 8 min, 4 users, load average: 0.14, 0.38, 0.25
Its contents are as follows:
12:38:33
Current time
Up 50days
System running time, format is hours: minutes
1 user
Number of currently logged in users
Load average: 0.06, 0.60, 0.48
System load, that is, the average length of the task queue. The three values are the average values from 1 minute, 5 minutes and 15 minutes ago to the present.
two。 Second and third behavior processes and CPU information
When there is more than one CPU, these may be more than two lines. The contents are as follows:
Tasks: 29 total
Total number of processes
1 running
Number of processes running
28 sleeping
Number of sleep processes
0 stopped
Number of processes stopped
0 zombie
Number of zombie processes
Cpu (s): 0.3% us
Percentage of CPU occupied by user space
1.0% sy
Percentage of CPU occupied by kernel space
0.0% ni
Percentage of CPU occupied by processes that have changed priority in user process space
98.7% id
Percentage of idle CPU
0.0% wa
Percentage of CPU time waiting for input and output
0.0% hi
0.0% si
3. Fourth and fifth behavior memory information.
The contents are as follows:
Mem: 191272k total
Total physical memory
173656k used
Total amount of physical memory used
17616k free
Total free memory
22052k buffers
Amount of memory used as kernel cache
Swap: 192772k total
Total amount of exchange area
0k used
Total number of switching areas used
192772k free
Total free exchange area
123988k cached
The total number of buffered swap areas. The contents of the memory are swapped out to the swap area, and then swapped into memory, but the used swap area has not been overwritten, and this value is the size of the swap area where these contents already exist in memory. When the corresponding memory is swapped out again, there is no need to write to the swap area.
two。 Process information
Column name
Meaning
PID
Process id
PPID
Parent process id
RUSER
Real user name
UID
User id of the process owner
USER
User name of the process owner
GROUP
The group name of the process owner
TTY
The terminal name of the startup process. Processes that are not started from the terminal are displayed as?
PR
Priority
NI
Nice value. Negative values indicate high priority, while positive values indicate low priority.
P
The final use of CPU makes sense only in a multi-CPU environment
% CPU
Percentage of CPU time spent since last update
TIME
Total CPU time used by the process, in second
TIME+
Total CPU time used by the process (in 100 seconds)
% MEM
Percentage of physical memory used by the process
VIRT
Total amount of virtual memory used by the process, in kb. VIRT=SWAP+RES
SWAP
The size swapped out in the virtual memory used by the process, in kb.
RES
The amount of physical memory used by the process and not swapped out, in kb. RES=CODE+DATA
CODE
The amount of physical memory consumed by executable code, in kb
DATA
The amount of physical memory occupied by parts other than executable code (data segment + stack), in kb
SHR
Shared memory size (in kb)
NFLT
Number of page errors
NDRT
The number of pages that have been modified since it was last written.
S
Process status.
D = uninterruptible sleep state
R = run
S = sleep
T = track / stop
Z = zombie process
COMMAND
Command name / Command Line
WCHAN
If the process is sleeping, the name of the system function in sleep is displayed
Flags
Task flag, refer to sched.h
The man command for top is explained as follows:
Listed below are top's available fields. They are always associated with the letter shown, regardless of the position you may have established for them with the 'o' (Order fields) interactive command.Any field is selectable as the sort field, and you control whether they are sorted high-to-low or low-to-high. For additional information on sort provisions see topic 3c. TASK Area Commands.
A: PID-Process Id
The task's unique process ID, which periodically wraps, though never restarting at zero.
B: PPID-- Parent Process Pid
The process ID of a task's parent.
C: RUSER-- Real User Name
The real user name of the task's owner.
D: UID-- User Id
The effective user ID of the task's owner.
E: USER-- User Name
The effective user name of the task's owner.
F: GROUP-- Group Name
The effective group name of the task's owner.
G: TTY-- Controlling Tty
The name of the controlling terminal. This is usually the device (serial port, pty, etc.) From which the process was started, and which it uses for input oroutput. However, a task need not be associated with a terminal, in which case you'll see'?' Displayed.
H: PR-- Priority
The priority of the task.
I: NI-- Nice value
The nice value of the task. A negative nice value means higher priority, whereas a positive nice value means lower priority. Zero in this field simply means priority will not be adjusted in determining a task's dispatchability.
J: P-Last used CPU (SMP)
A number representing the last used processor. In a true SMP environment this will likely change frequently since the kernel intentionally uses weak affinity. Also, the very act of running top may break this weak affinity and cause more processes to change CPUs more often (because of the extra demand for cpu time).
K:% CPU-- CPU usage
The task's share of the elapsed CPU time since the last screen update, expressed as a percentage of total CPU time. In a true SMP environment, if 'Irix mode' is Off, top will operate in' Solaris mode' where a task's cpu usage will be divided by the total number of CPUs. You toggle 'Irix/Solaris' modes with the' I 'interactive command.
L: TIME-- CPU Time
Total CPU time the task has used since it started. When 'Cumulative mode' is On, each process is listed with the cpu time that it and its dead children has used. You toggle 'Cumulative mode' with' S', which is a command-line option and an interactive command. See the 'S'interactive command for additional information regarding this mode.
M: TIME+-- CPU Time, hundredths
The same as' TIME', but reflecting more granularity through hundredths of a sec ond.
N:% MEM-Memory usage (RES)
A task's currently used share of available physical memory.
O: VIRT-- Virtual Image (kb)
The total amount of virtual memory used by the task. It includes all code, data and shared libraries plus pages that have been swapped out. (Note: you can define the STATSIZE=1 environment variable and the VIRT will be calculated from the / proc/#/state VmSize field.)
VIRT = SWAP + RES.
P: SWAP-- Swapped size (kb)
The swapped out portion of a task's total virtual memory image.
Q: RES-- Resident size (kb)
The non-swapped physical memory a task has used.
RES = CODE + DATA.
R: CODE-- Code size (kb)
The amount of physical memory devoted to executable code, also known as the'text resident set' size or TRS.
S: DATA-Data+Stack size (kb)
The amount of physical memory devoted to other than executable code, also known the 'data resident set' size or DRS.
T: SHR-- Shared Mem size (kb)
The amount of shared memory used by a task. It simply reflects memory that could be potentially shared with other processes.
U: nFLT-- Page Fault count
The number of major page faults that have occurred for a task. A page fault occurs when a process attempts to read from or write to a virtual page that is not currently present in its address space. A major page fault is when disk access is involved in making that page available.
V: nDRT-- Dirty Pages count
The number of pages that have been modified since they were last written to disk. Dirty pages must be written to disk before the corresponding physical memory location can be used for some other virtual page.
W: s-- Process Status
The status of the task which can be one of:
'D' = uninterruptible sleep
'R' = running
'S' = sleeping
'T' = traced or stopped
'Z' = zombie
Tasks shown as running should be more properly thought of as' ready to run'-- their task_struct is simply represented on the Linux run-queue. Even without a true SMP machine, you may see numerous tasks in this state depending on top's delay interval and nice value.
X: Command-- Command line or Program name
Display the command line used to start a task or the name of the associated program. You toggle between command line and name with 'c', which is both a command-line option and an interactive command. When you've chosen to display command lines, processes without a command line (like kernel threads) will be shown with only the program name in parentheses, as in this example: (mdrecoveryd) Either form of display is subject to potential truncation if it's too long to fit in this field's current width. That width depends upon other fields selected, their order and the current screen width.
Note: The 'Command' field/column is unique, in that it is not fixed-width. When displayed, this column will be allocated all remaining screen width (up to the maximum 512 characters) to provide for the potential growth of program names into command lines.
Y: WCHAN-- Sleeping in Function
Depending on the availability of the kernel link map ('System.map'), this field will show the name or the address of the kernel function in which the task is currently sleeping. Running tasks will display a dash ('-') in this column.
Note: By displaying this field, top's own working set will be increased by over 700Kb. Your only means of reducing that overhead will be to stop and restart top.
Z: Flags-- Task Flags
This column represents the task's current scheduling flags which are expressed in hexadecimal notation and with zeros suppressed. These flags are officially documented in. Less formal documentation can also be found on the 'Fields select' and' Order fields' screens.
By default, only the more important PID, USER, PR, NI, VIRT, RES, SHR, S,% CPU,% MEM, TIME+, COMMAND columns are displayed.
2.1 use keyboard shortcuts to change the display.
(1) change the content of the display. You can select what is displayed through the f key.
Press the f key to display the list of columns, press amurz to show or hide the corresponding columns, and finally press enter to determine.
(2) Press the o key to change the display order of the columns.
Press lowercase Amurz to move the corresponding column to the right, and uppercase Amurz to move the corresponding column to the left. Finally, press the enter key to confirm.
Press the uppercase F or O key, and then press amurz to sort the processes by the corresponding columns. The uppercase R key reverses the current sort.
Press enter to return to the interface after setting up.
three。 Command u
For details, please refer to the MAN help documentation. Here are some of the contents:
Command format:
Top [-] [d] [p] [Q] [c] [C] [S] [n]
Parameter description:
D: specifies the time interval between every two screen information refreshes. Of course, the user can use the s interactive command to change it.
P: monitor only the status of a process by specifying the monitoring process ID.
Q: this option will allow top to refresh without any delay. If the caller has superuser privileges, top will run at the highest possible priority.
S: specify accumulation mode
S: make the top command run in safe mode. This removes the potential danger of interactive commands.
I: make top not show any idle or dead processes.
C: display the entire command line instead of just the command name
In the display window of the top command, we can also type the following letters to do some interaction:
The help documentation is as follows:
Help for Interactive Commands-procps version 3.2.7
Window 1:Def: Cumulative mode Off. System: Delay 4.0 secs; Secure mode Off.
Z Global B Global:'Z 'change color mappings;' B 'disable/enable bold
L load avg; m Toggle Summaries:'l 'load avg;' t 'task/cpu stats; 'm' mem info
1Magi I Toggle SMP view:'1' single/separate states;'I 'Irix/Solaris mode
F,o. Fields/Columns:'f 'add or remove;' o' change display order
F or O. Select sort field
. Move sort field:''next col right
R,H. Toggle:'r 'normal/reverse sort;' H' show threads
C,i,S. Toggle:'c 'cmd name/line;' I 'idle tasks;' S' cumulative time
X,y. Toggle highlights:'x 'sort field;' y 'running tasks
Z,b. Toggle:'z 'color/mono;' b 'bold/reverse (only if' x'or 'y')
U. Show specific user only
N or #. Set maximum tasks displayed
KJI r Manipulate tasks:'K 'kill;' r 'renice
D or s Set update interval
W Write configuration file
Q Quit
(commands shown with'. Require a visible task display window)
Press'h' or'?' For help with Windows
H or?: show the help screen and give some short summary instructions for the command.
K: terminates a process. The user will be prompted to enter the process PID that needs to be terminated and what kind of signal needs to be sent to the process. A general termination process can use a 15 signal; if it does not end properly, use signal 9 to force the process to end. The default value is signal 15. This command is blocked in safe mode.
I: ignore idle and dead processes. This is a switch command.
Q: exit the program.
R: rearrange the priority of a process. The user is prompted to enter the process PID that needs to be changed and the process priority value to be set. Entering a positive value lowers the priority, otherwise it gives the process a higher priority. The default value is 10.
S: switch to cumulative mode.
S: change the delay time between refreshes. The user will be prompted to enter a new time in s. If there is a decimal, it is converted to ms. Enter a value of 0 and the system will continue to refresh, with a default value of 5 s. It should be noted that if you set too little time, it is likely to cause continuous refresh, so that it is too late to see the display at all, and the system load will be greatly increased.
F or F: add or remove items from the current display.
O or O: change the order in which items are displayed.
L: toggle to display average load and startup time information. That is, the first line of the shadow collection is displayed
M: toggles the display of memory information. That is, the shadow memory line is displayed
T: toggles the display of process and CPU status information. That is, display the shadow CPU line
C: toggles the display command name and the full command line. Displays the complete command. This feature is very useful.
M: sort according to the resident memory size.
P: sort according to the percentage of CPU usage.
T: sort by time / cumulative time.
W: writes the current settings to the ~ / .toprc file. This is the recommended way to write top configuration files.
Thank you for reading this article carefully. I hope the article "how to use Top commands in Linux" shared by the editor will be helpful to everyone. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.