Linux top commands

Source: Internet
Author: User
Tags superuser permission

The top command is a performance analysis tool used in linux to display the resource usage of various processes in the system in real time. It is the same as the job manager in windows. The following describes how to use it:

[Root @ test etc] # top

Top-16:20:18 up 243 days, 2 users, load average: 3.09, 2.15, 1.23
Task: 328 total, 1 running, 326 sleeping, 0 stopped, 1 zombie
Cpu (s): 0.5% us, 2.4% sy, 0.0% ni, 85.0% id, 12.1% wa, 0.0% hi, 0.0% si
Mem: 8173716 k total, 8132856 k used, 40860 k free, 111376 k buffers
Swap: 8385920 k total, 366748 k used, 8019172 k free, 6481144 k cached

Pid user pr ni virt res shr s % CPU % mem time + COMMAND

1 root 16 0 4772 436 S 404 0.0. 48 init

I. Statistical information area

The first five lines are the overall statistics of the system.

(1)The first line is the task queue information, similar to the execution result of the uptime command.

[Root @ test etc] # uptime
16:20:18 up 243 days, 2 users, load average: 3.09, 2.15, 1.23
Introduction:

16:20:18, current time

Up 243 days, system running days and system running time, format: minute

2 users: current number of logged-on users

Load average 3.09, 2.15, 1.23, system load, that is, the average length of the task queue. (3.09, 2.15, 1.23) these three values are the average values from 1 minute, 5 minutes, and 15 minutes ago to the present.

(2)Second and third behavior processes and cpu information. If there are multiple CPUs, the content may exceed two lines.

Introduction:

Tasks: 328 total, total Processes

1 running: Number of running Processes

326 sleeping: Sleep Process

0 stopped, number of stopped Processes

1 zombie, number of zombie Processes

------------------------

Cpu (s): 0.5% us, percentage of cpu occupied by user space

2.4% sy, cpu usage in kernel space

0.0% ni: cpu usage of processes with a higher priority in the process space

85.0% id, percentage of idle cpu

12.1% wa, cpu time percentage waiting for Input and Output

0.0% hi

0.0% si

(3)Memory information of the last two behaviors

The content is as follows:

Mem: 8173716 k total, total physical memory

8132856 k used, total physical memory used

40860 k free, total idle memory

111376 k buffers, memory used as the kernel Cache

----------------------

Swap: 8385920 k total, total number of Swap Areas

366748 k used, the total number of swap areas used

8019172 k free, total number of free swap Areas

6481144 k cached, total cache swap Zone

Relationship between memory and swap zone:

The content in the memory is swapped out of the SWAp zone and then into the memory, but the used swap zone has not been overwritten,

This value indicates the size of swap areas in which the memory already exists.

When the corresponding memory is swapped out again, you do not have to write data to the swap zone.

2. Process Information Zone

PID, process ID

USER: the USER name of the process owner.

PR, priority

NI, nice value/negative value indicates high priority, positive value indicates low priority

VIRT: Total virtual memory used by the process, in kb. VIRT = SWAP + RES

RES, the size of the physical memory used by the process, not swapped out, in kb. RES = CODE + DATA

SHR, shared memory size, in kb

S, Process status (D = non-disruptive sleep status; R = running; S = sleep; T = tracking/stopping; Z = zombie process)

% CPU, percentage of CPU time occupied since the last update

% MEM, percentage of physical memory used by the Process

TIME +, total cpu time used by the process, in the unit of 1/100 seconds

COMMAND, COMMAND name/COMMAND line

By default, only important PID, USER, PR, NI, VIRT, RES, SHR, S, % CPU, % MEM, TIME +, and COMMAND columns are displayed.

You can use the following shortcut keys to change the display content:

1.Press the f key to select the displayed content. Press f to display the column list. Press a-z to display or hide the corresponding column, and press enter to confirm.

2. Press the o key can change the display order, press lowercase a-z can move the corresponding column to the right, and the upper A-Z can move the corresponding column to the left. Press enter.

3. Press the F or O key in upper case, and then sort a-z processes by corresponding columns. The uppercase R key can reverse the current sorting.

Iii. command usage

(1). Command name: top

(2). command functions

Displays the current process and other conditions of the system. top is a dynamic display process, which allows you to refresh the current state by pressing the buttons. if you execute the change command on the foreground, it will exclusively occupy the foreground until the user terminates the program. the top command provides system processor status monitoring. displays the list of CPU-sensitive tasks in the system. this command can be used by CPU. the memory uses and runs to sort tasks. Many features of this command can be set through interactive commands or in a custom file.

(3). Environment Settings

Use in linux

(4). Usage

1. Use format

Top [-] [d] [p] [q] [c] [C] [S] [s] [n]

2. parameter description

D. Specify the interval between two screen information refreshes. Of course, use the s interactive command to change.

P usually specifies the monitoring process ID to only monitor the status of a process.

Q This option will refresh top processes without any delay. If the calling program has the superuser permission, top will run with the highest possible priority.

S indicates the accumulative mode.

S enables the top command to run in safe mode. This removes the potential danger of interactive commands.

I so that top does not display any restrictions or zombie Processes

C. display the entire command line, not just the command name.

3. Miscellaneous

Some interactive commands that can be used during top command execution. From the perspective of usage, understanding these commands is more important than understanding the options. These commands are single-letter,If the s option is used in the command line option, some of the commands may be blocked..

Ctrl + L erase and override the screen

H or? Displays the help screen and provides some brief command Summary

K. terminate a process. The system improves the PID of the process to be terminated and the signal to be sent to the process. Generally, 15 signals can be used to terminate a process. If the process cannot end normally, use signal 9 to forcibly end the process. The default value is signal 15. This command is blocked in security mode.

I ignore idle and dead processes. This is a switch-on command.

Q releases a program.

R reschedule a process with priority. The system prompts the user to enter the process PID to be changed and the process priority value to be set. Entering a positive value will lower the priority, and vice versa will give the process a higher priority. The default value is 10.

S switches to the accumulative mode .?

S changes the delay time between two refreshes. The system prompts the user to enter a new time in seconds. If there is a decimal number, it is converted to m s. If the input value is 0, the system will be refreshed continuously. The default value is 5 s. It should be noted that if the setting is too small, it is likely to cause constant refresh, so it is too late to see the display, and the system load is also greatly increased.

F or F: add or delete a project from the current display.

O or O changes the order of projects displayed.

L switching displays average load and startup time information.

M switch Display memory information

T Switch displays process and cpu status information

C switch display command name and complete command line

M is sorted by resident memory size

P sort by CPU usage percentage

T sort by time/accumulative time

W write the current settings ~ /. Toprc file. This is a recommended method for writing top configuration files.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.