Top of Linux commands

Source: Internet
Author: User

TOP–HV | -abchimmss–d delay–n iterations–p pid [, PID ...]

The top program provides a dynamic, real-time view of the running system that displays system profiles and a list of tasks currently managed by the Linux kernel. The types of system profiles shown, as well as the type, order, and size of information displayed for a task, are user-configurable, and can be configured to remain unchanged on restart.

The program provides a limited number of interaction excuses for process operations, and does not provide a broader interface for personal configuration-including aspects of its operations. Although top is referenced throughout the document, you can name any program you want. The new name, which can be an alias, will be reflected on the top of the monitor and used when reading and writing the configuration file.

(1). What are the meanings of some fields in top

Virt:virtual Memory usage Virtual RAM

1. The process "required" virtual memory size, including the library, code, data, etc. used by the process

2, if the process to apply for 100M of memory, but the actual use of only 10M, then it will grow to 100M, rather than the actual amount of

Res:resident Memory Usage resident RAM

1. The memory size currently used by the process, but does not include swap out

2. Sharing with other processes

3, if the application 100M memory, the actual use of 10M, it only grows 10M, and virt opposite

4, about the memory consumption of the library, it only statistics the size of the loaded library file memory

Shr:shared Memory Shared

1, in addition to the shared memory of the process itself, also includes the shared memory of other processes

2, although the process uses only a few shared library functions, but it contains the entire size of the shared library

3, the calculation of the physical memory of a process accounted for the formula: RES-SHR

4. After Swap out, he will descend

DATA

1, the memory occupied by the data. If the poll is not displayed, press the F key to display it.

2, the real data space required by the program is really in operation to use.

(2). Options

-A sorts by memory usage. The most important thing about this switch is to sort the processes by allocating memory. -B Batch mode operation. Start top in batch mode, which can be used to send output from top to other programs or files. In this mode, top will not accept input and run until you use the '-n ' command-line option to set the limit iteration count or until it is killed. -C command Line/program name switch. Start top Invert (toggle) The last remembered ' C ' state. Therefore, if top displays the command line, the field now displays the program name and vice versa. -D delay Interval is:-D ss.tt (in seconds, allow decimals, do not allow negative numbers). Specifies the delay between screen updates and overrides the corresponding values in the personal profile or startup defaults. You can then change this by using the ' d ' or ' s ' interactive command. Only root in Safe mode can change this class (unless you use the ' s ' command-line option)-H to help information-H thread switching. Start top Invert (toggle) The last remembered ' H ' state. When you switch to ON, all faded threads are displayed. Otherwise, top displays the sum of all threads in the process. -I idle process switch. Start top Invert (toggle) The last remembered ' I ' state. When this switch is off, the idle or zombie task-M virt/used switch is not displayed. The report is used (the total number of process RSS and the total number of interchanges), not virtual memory. -M detects the internal deposit element. Displays the inner deposit cell (k/m/g) and displays the floating-point number-n iteration limit in the Memory Digest to:-N. Specifies the maximum number of iterations or frames that should be produced before the end. -P monitor PID:-PN1–PN2 ... or-pn1,n2[,...]. Only processes with the specified process ID are monitored. This option can be given up to 20 times, or you can provide a comma-separated list of up to 20 pid. Mixing these two methods is run. If you want to return to normal operation, just issue the ' = ' interactive command. -S Safe mode operation. Force startup of Safe mode, even if it is root. This mode can be better controlled through the system configuration file. -S cumulative time mode toggle. Start top Invert (toggle) The last remembered ' S ' state. When the cumulative mode is on, each process lists the CPU time that it and its dead child processes use. -U user monitoring:-u somebody. Only processes that match a given valid UID or user name are monitored-u user monitoring:-u somebody. Only processes that match the given UID or user name are monitored. This matches the actual, valid, and saved file system UID. -V Version Information

(3). Interactive commands

1) Global command

< enter >/< spaces > Refresh the display.

? /h Help

= Exits the task limit. Removes restrictions that display tasks. This command reverses any ' I ' (idle Task) and ' n ' (maximum task command) that may be active. It also provides the ' exit ' of PID monitoring.

A alternate display mode switch. This command toggles between full screen mode and change display mode

B bold Disable/enable toggle. This command affects the use of the "bold" terminal feature and changes the summary area and task area of the current window (note: When this switch is on and top is running in monochrome mode, the entire display will be displayed as normal text.) So unless the ' x ' or ' y ' switch uses the inverse emphasis, there will be no visual proof that they are on. )

D/S change the delay interval. You will be prompted to enter a delay time (in seconds) between the display updates. Fractional seconds are worthwhile, but negative numbers are not allowed. Input 0 results in almost continuous updates, and the display is unsatisfactory because the system and TTY driver views meet the highest requirements. The delay value is inversely proportional to the system load and is therefore carefully set. If you want to know the current delay time at any time, just ask for help and view the system summary on the second line.

G Select another window or field group. You will be prompted to enter a number from 1 to 4, specifying the window/field group that should be the current window.

I irix/solaris mode switch. When running under Solaris mode (' I ' switch to OFF), the CPU utilization of the task is divided by the total number of CPUs. After you issue this command, you will be notified of the new state of the switchover.

U Select a user. You will be prompted to enter the UID or user name. Only processes that belong to the selected user are displayed. This option matches the valid UID

U Select a user. You will be prompted to enter the UID or user name. Only processes that belong to the selected user are displayed. This option matches the true, valid, reserved, and UID of the file system

K Kills a task (process). You will be prompted to enter a PID and then enter the signal to be sent. The default signal as reflected in the hint is sigterm. However, you can send any signal by number or name. If you want to stop the kill process, you can press <Enter>; at the PID prompt and press 0 at the signal prompt.

Q Exit.

R re Nice a task. You will be prompted to enter a PID and then enter a nice value to it. Entering a positive value causes the process to lose its priority. Conversely, negative values will cause the process to be more easily viewed by the kernel.

W write the configuration file. This will save all options and toggles as well as the current display mode and delay. By issuing this command before exiting top, you can restart in exactly the same state later.

Z Change the color map. This key will take you to a separate screen where you can change the color of the current window or all windows

Note: Commands in the blue font are not available in Safe mode and are not displayed on the Level 1 help screen.

2) Summary Area Command

L LOAD the average/uptime switch. The red line that is displayed.

M memory/swap usage switch. Two lines of Red displayed

T task/cpu states switch. The red area that is displayed. If you use the 1 command, the CPU states line may be multiple lines.

1 the entire/separate CPU status switch. Shows the differences between the two.

Note: If you switch the entire summary area of any window to off, only the message line is left. This allows you to maximize the available task rows, but temporarily sacrifices the program name or the current window name in the full-screen mode in alternate display mode.

3) Task Area Command

1. Task Window appearance

b Bold switch. This command affects the display of the X and Y commands. And only these two commands have an open to be available.

X-column Highlight switch. Changes the highlight of the current sort field.

Y-line highlight switch. Changes the highlighting of a running task (process).

Z Color/monochrome switch. The current window color in the last use of the color, white black, black on the bottom of the switch between words. , this command changes the summary area and the task area, but does not affect the x,y,b command.

2. Task Window Contents

C command Line/program name toggle. Whether ' Command ' is present or not, it needs to be followed.

f/o field to select or Sort fields. These keys display a separate screen where you can change which fields are displayed and in which order.

H thread switch. When this switch is turned on, all individual threads are displayed. Otherwise, the top shows the sum of all threads in the process.

S cumulative time mode switch. When the cumulative mode is turned on, each process lists the CPU time that it and its dead child processes use. When closed, the program that divides many separate tasks will appear to be low-demand. It is appropriate for programs like "Init" or shell, but for others, such as compilers, maybe not. Try two task Windows to share the same sort field, but use a different ' S ' state to see which expression you prefer. After you issue this command, you will be notified of the new state of this switch. If you know in advance whether the cumulative mode is working, just ask for help and see a summary of the window on the second line.

U displays only specific users. You will be prompted to enter the name of the user to display. After that, only the user ID is displayed in the Task window or it may not display any tasks. Later if you want to monitor all tasks again, republish this command, but simply press <enter> at the prompt, instead of providing a name.

3. Task Window Size

I idle process switch. Show All tasks or just active tasks. When this switch is off, idle or zombie processes are not displayed. If you apply the command to the last task display in alternating display mode, it will not affect the size of the window because all previous task displays have been drawn.

n/# set the maximum task. You will be prompted to enter the number of tasks to display. When used in alternating display mode, this command can precisely control the size of each currently visible task display, except for the last one. It does not affect the size of the last window because all previous task displays have been drawn.

Note: If you want to increase the size of the last visible task display in alternating display mode, simply reduce the size of the task displayed above it.

4. Task window sorting

Top recommends that you use the ' X ' Exchange command to temporarily open column highlighting before using the following collation. This will help the actual sort environment to match your intentions. The following interactive commands are satisfied only if the current sort field is visible. The reason that the sort field is not visible may be that the screen is not wide enough; the ' F ' interactive command is off.

< move the sort field to the left. If the current sort field is the first field that is displayed, the column is moved to the left.

> Move the Sort field to the right. Moves the column to the right unless the current sort field is the last field displayed.

F/O Select the Sort field. These keys display a separate screen where you can change which fields are used for sorting. If you select a field that is not previously displayed, it is forced to open when you return to the top display. However, depending on your screen width and field order, the secondary sort may not be displayed. This interactive command can simply verify the current sort field when the top run-time column is highlighted as closed.

R Reverse/normal sort field toggle. With this interactive command, you can switch between high-down or low-to-high sorting.

Note: field sorting uses internal values instead of values in the column display. Therefore, the TTY and Wchan fields will violate the strict ASCII sort order.

4) Color Mapping

When you issue a ' Z ' interactive command, you will see a separate screen. This screen can be used to change the color of the current window or all windows before returning to the top display. In this separate screen, 4 uppercase selection targets are displayed, and 8 numbers are selected for the color. There is also a B for bold switch, B to run the task bold switch, Z for color/monochrome switch,<enter> represents the application and exit, A/W represents the request and go to the next/previous, q means to discard the changes and exit.

(4). Example

[[email protected] Desktop]# toptop-02:18:19 up 10:07, 3 users, load average:0.79, 0.70, 0.65tasks:174 total, 1 ru Nning, 173 sleeping, 0 stopped, 0 zombiecpu (s): 2.8%us, 1.5%sy, 0.0%ni, 95.7%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st mem:1907300k Total, 1127804k used, 779496k free, 54300k buffersswap:4095996k total, 0k used, 4095996k F   REE, 407984k cached PID USER PR NI VIRT RES SHR S%cpu%MEM time+ COMMAND 2053 Root 20 0 243m 76m 13m s 13.6 4.1 5:59.58 Xorg 2665 root 0 348m 18m 11m S 11.0 1.0 1:03.91 G     Nome-terminal 2739 Root 0 1252m 289m 53m S 7.3 15.5 25:59.39 Firefox 4 root 20 0                    0 0 0 S 0.3 0.0 0:01.53 ksoftirqd/0 5486 root 0 15032 1288 936 R 0.3 0.1 0:00.09 Top     1 Root 0 19352 1548 1228 S 0.0 0.1 0:02.38 init 2 root 20 0 0  0 0 S 0.0 0.0 0:00.01 Kthreadd 3 root RT 0 0 0 0 S 0.0 0.0 0:00.44 migration/0 5 root RT 0 0 0 0 S 0.0 0.0 0:00.00 stopper/0 6 root RT 0 0 0 0 S 0.0 0.0 0:0    0.09 watchdog/0 7 root RT 0 0 0 0 S 0.0 0.0 0:00.08 MIGRATION/1 8 root RT  0 0 0 0 S 0.0 0.0 0:00.00 STOPPER/1 9 Root 0 0 0 0 S 0.0 0.0 0:01.17      KSOFTIRQD/1 Root RT 0 0 0 0 S 0.0 0.0 0:00.19 WATCHDOG/1 one root 20 0 0 0 0 S 0.0 0.0 0:22.94 events/0 Root 0 0 0 0 S 0.0 0.0 0:04.39 Eve  NTS/1 Root 0 0 0 0 S 0.0 0.0 0:00.00 events/0

Summary Area field parsing:

1) Task line information, with uptime command execution result

Top-02:18:19 current system time, updated with screen update

Up 10:07 system uptime, hh:mm (Hours: minutes)

3 Users 3 User

Load average:0.79, 0.70, 0.65 system payload, which is the average length of the task list

2) Task (process)

tasks:174 Total Process Count

1 running number of running processes

173 sleeping The number of sleep processes

0 Number of processes stopped stopped

0 Zombie of frozen processes

3) CPU status information

CPU (s): 2.8%us user space consumes CPU percentage

1.5%sy CPU percent of kernel space consumed

0.0%ni CPU Percentage of processes that have changed priority within the user process space

95.7%id Idle CPU Percentage

0.0%wa the percentage of input and output waiting to occupy the CPU

0.0%hi Hard Interrupt (Hardware IRQ)% of CPU occupied

0.0%si Soft interrupt (software interrupts)% of CPU occupied

0.0%st (Don't know)

4) Memory Information

mem:1907300k Total Physical Memory

1127804K used total Memory used

779496k free Memory Total

The amount of memory in 54300k buffers cache

5) Swap swap partition information

Total swap area of swap:4095996k

Total swap area used by 0k used

4095996k Free Swap Area total

407984k cached cache of the total swap area, you can use swap memory

Task (process) Area field resolution:

PID process ID. The unique process ID of the task, which is periodically encapsulated, but does not start with the PPID parent process ID starting from 0. The parent process of the task Idruser the real user name. The real user name UID User ID of the task owner. The user Iduser user name that is valid for the task owner. Valid user name Group name for the task owner. Valid group name for the task owner TTY control terminal. The name of the control terminal. It is usually the device that initiates the process (serial interface, pty Virtual terminal, etc.) for input and output. However, the task does not have to be contacted by the terminal, and you will see the display '? ' PR priority. Priority NI Nice value for the task. The nice value of the task. A negative nice value means a higher priority, while a positive nice value means a lower priority. In this field, 0 means that the priority is not adjusted when the task is scheduled. The last CPU used in P is meaningful only in a multi-CPU environment. %cpu use of the CPU. The percentage of CPU time that the task has elapsed since the last screen refresh, in total CPU time. Time of the CPU (in seconds). The total CPU time that the task has been using since it was started. When ' cumulative mode ' is on, each process lists the CPU time used by its and its dead child processes. Time+ CPU time, 1% seconds. Same as time but accurate to percentile. %MEM Memory Usage (RES). The amount of available physical memory that the task is currently using (percentage) VIRT virtual image (in kilobytes). The total amount of virtual memory used by the task. It includes all code, data, and shared libraries, as well as pages that have been swapped. Virt=swap+res (Note that you can define an environment variable statsize=1,virt will be calculated from the Proc/#/status vmswap field. Swap swap memory (in kilobytes). Each process exchange value is taken from Proc/#/status Vmswapres resident memory (in kilobytes). Non-exchangeable physical memory used by a task. Res=code+datacode code size (in kilobytes). The amount of physical memory dedicated to executable code, also known as the ' text resident set ' size or TRS. Data + stack size (in kilobytes). In addition to the amount of physical memory outside the executable code, also known as the ' data resident set ' size or Drs. SHR Shared memory size (in kilobytes). The amount of shared memory used by the task. It simply reflects the memory that may be shared with other processes. Nflt page Error count. The number of main page faults that the task occurred. A page fault occurs when a process attempts to read or write to a virtual page that does not currently exist in its address space. A major page error involves disk access when the page is made available. NDRT Dirty page count. The number of pages modified since the last time the disk was written. You must firstDirty pages are written to disk before the corresponding physical memory location can be used for other virtual pages. S process state. d= uninterrupted sleep, r= is running, s= sleep, t= tracking or stopping, z= zombies (process). Tasks that appear to be running should be more appropriately considered ready to run-their task_struct are only represented in the Linux runtime queue. Even without a real SMP machine, you can see many tasks in this state, depending on the top delay interval and nice values. command line or program name. Displays the command line or the associated program name used to start the task. You can use ' C ' to switch between the command line and the name, which is the command-line option and the interactive command. Wchan the function in sleep. Depending on the availability of the kernel link map (' Stase.map '), this field displays the name or address of the kernel function that the task is currently sleeping on. The task that runs will display a dash ('-') in this column. Flags task flags. This column represents the current dispatch flag for the task, expressed in hexadecimal notation, and contains 0. These signs are officially recorded in <linux/sched.h>. You can also find less formal documents on the field selection and order fields screens.

Only the more important PID, USER, PR, NI, VIRT, RES, SHR, S,%cpu,%MEM, time+, and COMMAND columns are displayed by default!

Top of Linux commands

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.