Top command usage for Linux

Source: Internet
Author: User
Tags command line current time memory usage safe mode sorts terminates time interval linux

Top command:

The top command and the PS command have the same basic role of displaying the current process and other conditions of the system, but top is a dynamic display process that refreshes the current state with the user key. Such as? The foreground executes the command, and he will monopolize the foreground until the user terminates the program.

More precisely, the top command provides real-time monitoring of the system's processor state. He will display a list of the most "sensitive" tasks for the CPU in the system. This command can be used by the CPU. The tasks are sorted by memory usage and execution time, and many of the commands can be set through interactive commands or in personal custom documents. The command arguments and the interaction commands are described separately in the following introduction.

The following is the syntax format for the command:

Top [-] [D delay] [Q] [C] [s] [s] [i]

d Specifies the time interval between refresh of the screen information every two times. Of course, users can use the s interactive command to change it.

Q This option will cause top to be refreshed without any delay. If the calling program has ultimate user rights, top will run at the highest possible priority level.

S Specifies the cumulative mode.

s makes the top command run in Safe mode. This removes the potential risk of interaction commands.

I make top do not show any idle or zombie processes.

C Displays the entire command line instead of just displaying the command name

The top command shows a lot of items, the default is updated every 5 seconds, of course, this can be configured. The items displayed are:

Uptime This item shows the system boot time, elapsed time, and three average load values (last 1 seconds, 5 seconds, 15 seconds).

Processes the total number of running processes since the most recent refresh. Of course, these processes are divided into running, dormant, stopped, and many other kinds. Processes and status displays can be implemented through interactive command T.

CPU States shows user mode, System mode, priority process (only the priority is negative) and the percentage of CPU time occupied by the various situations such as idle. The time that the priority process consumes is also included in the user and system time, so the total percentage will be greater than 100%.

Mem memory usage statistics, which includes total available memory, free memory, used memory, shared memory, and cache memory.

Swap space statistics, which includes the total swap space, available swap space, the swap space has been used.

PID ID of each process.

PPID the parent process ID of each process.

UID of any person for each process.

User name of any person per process.

The PRI's priority level for each process.

NI the priority value of the process.

Size the code size of the process plus the data size plus the total stack space size. The Unit is KB.

Tsize the code size of the process. This is a very strange value for the kernel process.

Dsize the size of the data and stack.

TRS text resident size.

D is marked as an "unclean" page item.

The size of the library page used by LIB. is not useful for elf processes.

RSS the total amount of physical memory consumed by this process, in kilobytes.

SHARE the number of shared memory that the process uses.

STAT the status of the process. where s represents the dormant state, D represents the Interruptible sleep state, R represents the running state, Z represents the zombie state, and T represents the stop or trace state.

The total CPU time that the process has consumed since it was started. If you enter a cumulative pattern, the time also includes the time that the process subprocess takes. And the title will become CTime.

%cpu the percentage of CPU time and total time that the process has consumed since the most recent refresh.

%mem The amount of physical memory that the process occupies as a percentage of the total memory.

command name of the process, if one row does not appear, will be intercepted. An in-memory process will have a complete command line.

The following are some of the interaction commands that you can use during the top command execution. From a usage standpoint, mastering these commands is more important than controlling the options. These commands are all single letters, and if the S option is used in command-line options, some of these commands may be blocked.

The $#@60 space immediately refreshes the display.

Ctrl L Erase and rewrite the screen.

H or? Displays the help screen, giving some brief summary instructions.

K Terminates a process. The user is prompted to enter the process PID that needs to be terminated, along with the signal that needs to be sent to the process. The general termination process can use 15 signals; if it doesn't end normally, 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 zombie processes. This is a switch command.

Q quit the program.

R to reschedule a process's priority level. The system prompts the user to input the process PID which needs to be changed along with the ping to escape the side burning ton of idle J Chung Yuen Guanidine Huan Jesus to the coat side burning Governor 蚰 芄 King Scale medium Escape the hot ād present stool? 0.

S conversion to cumulative mode.

s changes the delay time between two times of refresh. The user will be prompted to enter a new time in the unit S. If there is a decimal, it is converted to M S. Enter a value of 0 and the system will refresh continuously with the default value of 5 S. It is important to note that if the configuration is too small time, it is likely to cause constant refresh, so it is too late to see the display of the situation, and the system load will be greatly increased.

F or F to add or remove items from the current display.

O or O change the order in which items are displayed.

The L conversion displays average load and start time information.

The M conversion displays memory information.

The T transformation displays process and CPU state information.

The C conversion displays the command name and the complete command line.

M sorts based on the size of the resident memory.

P is sorted according to the percentage size used by the CPU.

T sorts according to time/cumulative time.

W writes the current configuration to the ~/.TOPRC document. This is the recommended method for writing the top configuration document.

As you can see from the above introduction, the top command is a powerful monitoring system tool, especially for system administrators. The average user may feel that the PS command is sufficient, but the strong function of the top command does provide a lot of convenience.

This paper url:http://www.bianceng.cn/os/linux/201410/45599.htm

Let's take a look at the actual usage:

$top

Top-05:05:28 up 1:19, 1 user, load average:0.11, 0.05, 0.01

tasks:54 Total, 1 running, sleeping, 0 stopped, 0 zombie

Cpu (s): 0.3% us, 1.0% sy, 0.0% ni, 98.0% ID, 0.3% wa, 0.3% Hi, 0.0% si

mem:1034496k Total, 230408k used, 804088k free, 16200k buffers

swap:2031608k Total, 0k used, 2031608k free, 160340k cached

PID USER PR NI virt RES SHR S%cpu%mem time+ COMMAND

6339 GDM 0 60212 13m 8020 S 0.7 1.3 0:14.73 Gdmgreeter

7421 Oracle 0 3416 964 768 R 0.7 0.1 Top

5319 Root 0 5200 2668 1340 S 0.3 0.3 0:08.27 Hald

6192 Root 0 29444 8364 2476 S 0.3 0.8 0:25.89 X

1 root 0 2232 552 472 S 0.0 0.1 0:00.77 Init

2 root RT 0 0 0 0 S 0.0 0.0 0:00.00 migration/0

3 Root 0 0 0 S 0.0 0.0 0:00.00 ksoftirqd/0

4 root 5-10 0 0 0 S 0.0 0.0 0:00.05 events/0

5 root 5-10 0 0 0 S 0.0 0.0 0:00.01 khelper

6 root 15-10 0 0 0 S 0.0 0.0 0:00.00 kacpid

Root 5-10 0 0 0 S 0.0 0.0 0:00.05 kblockd/0

Root 0 0 0 0 S 0.0 0.0 0:00.00 KHUBD

0 0 0 0 S 0.0 0.0 0:00.00 Pdflush

0 0 0 0 S 0.0 0.0 0:00.24 Pdflush

0 0 0 0 S 0.0 0.0 0:00.00 kswapd0

14-10 0 0 0 S 0.0 0.0 0:00.00 aio/0

189 Root 0 0 0 0 S 0.0 0.0 0:00.00 kseriod

The first line of items is the current time, the system start time, the number of current system logged-in users, and the average load.

The second behavior process is the total number of processes, the number of running processes, the number of dormant processes, the number of zombie processes, and the number of terminating processes.

The third behavior of the CPU state, in turn, user occupancy, system occupancy, priority process occupation, idle process occupied.

The four-act memory state, in turn, is the average available memory, used memory, free memory, shared memory, cache usage memory.

The behavior Exchange state, in which the average available exchange capacity, used capacity, idle capacity, cache capacity are followed. Then there is the list of processes that are similar to PS.

This article is from "Richard's notes-accumulate micro Cheng" blog, please be sure to keep this source http://zxf261.blog.51cto.com/701797/886331

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.