Introduction to Linux/unix Task Manager-top command usage

Source: Internet
Author: User
Tags current time memory usage sleep cpu usage

Task Manager under Windows is not good (individuals prefer process Explorer some), but also convenient, can easily view the process, CPU, memory ... And it's easy to end the process.

There is no GUI Linux, there are commands to implement Windows Task Manager function, the command is "top", userscan use top to sort processes, end processes, and so on.

The top command is a commonly used performance analysis tool under Linux, which can display the resource consumption status of each process in real time, and the default 5 seconds to refresh the process list, so it is similar to Windows Task Manager.

Statistical information of the whole system at present

The first five elements displayed by the top command are statistical information for the system as a whole.

The first line is the task queue information, with the execution result of the uptime command . eg.

Top-15:09:51 up, 3:38, 4 users, Load average:1.09, 3.39, 4.76

15:09:51 Current time
up to days, 3:38 system run time, format last: Min
4 users currently logged in
Load average:1.09, 3.39, 4.76 system load, which is the average length of the task queue.
Three values are 1 minutes, 5 minutes, and 15 minutes ago to the current average.

The second to third behavior process and CPU information. When you have more than one CPU, the content can be more than two lines. eg.

tasks:115 Total, 1 running, 114 sleeping, 0stopped, 0zombie
Cpu (s): 16.1% us, 2.0% sy, 0.0% ni, 79.5% ID, 1.4% wa, 0.0% Hi, 1.0% si

Total process tasks:115
1 Running number of processes running
114 Sleeping Number of sleep processes
0 stopped Number of process stops
0 Zombie Number of zombie processes
CPU (s): 16.1% US user space uses CPU percent
2.0% Sy kernel footprint CPU percent
0.0% ni % of processes in user process space that have changed priority
79.5% ID idle CPU percent
1.4% wa % CPU time waiting for input output
0.0% Hi
0.0% si

The last two acts of memory information. eg.

mem:8169876 k Total, 7686472 K used, 483404 K-free, 35272 K buffers
swap:4096532 k Total, 160 k used, 4096372 K-free, 2477532 K Cached

mem:8169876 ktotal Total Physical Memory
Total physical memory used by 7686472 K used
483404 k free memory Total
35272 K buffers as the memory of the kernel cache
swap:4096532 k Total Total Swap partition
Total number of swap areas used by 160 K used
4096372 k free idle swap area total
Total number of swap areas 2477532 K cached buffers.

The content in memory is swapped out to the swap area and then swapped into memory, but the used swap area has not been overwritten, which is the size of the swap area where the content already exists in memory. When the corresponding memory is swapped out again, you do not have to write to the swap area again.

Process information

The details of each process are shown below the statistical information area. First of all, to understand the meaning of the columns.

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

Ordinal column name meaning
pid    process ID
ppid    parent process ID
ruser    realusername
uid    The user ID of the process owner
user    The user name of the process owner
group    The group name of the process owner
tty    the terminal name of the process to start. Processes that are not started from the terminal are displayed as? The
pr    priority
ninice     value. A negative value indicates a high priority, and a positive value indicates the lower priority
p    last used CPU, only meaningful in a multiple-CPU environment
%cpu    Last updated to the current percentage of CPU time consumed
Total CPU time used by the time    process, in per second
time+    total CPU time used by the process, in units 1/100 seconds
%mem   Percentage of physical memory used by the   process
The total amount of virtual memory used by the virt    process, in kilobytes. Virt=swap+res The amount of virtual memory used by the
swap    process, swapped out in kilobytes.
The amount of physical memory that the res    process uses, not swapped out, in kilobytes. Res=code+data
code    The amount of physical memory used by executable code, in kilobytes
data    the amount of physical memory occupied by parts other than executable code (data segment + stack) , in units KB
shr    shared memory size, per unit KB
nflt    page error times
ndrt    last written to now, The number of pages that have been modified.

S process status.
D= an uninterrupted sleep state
R= Run
S= Sleep
t= Tracking/Stopping
z= Zombie Process

Command name/command line
Wchan If the process is sleeping, the name of the system function in sleep is displayed
Flags task flags, reference sched.h

Sort by specified column

Top can be set to sort by an item, by default, by CPU usage,

M, (note capitalization), sorted by memory usage

P, sorted based on percentage size of CPU usage

T, sorted according to TIME/cumulative time.

How to end a process

Enter the letter k(lowercase) and then enter the PID you want to kill

Of course you can also directly run the command, kill PID

Top Other usage

Other uses of top, you can go to the top command help interface by losing "H" in the Top interface

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.