用途

查看机器负载以及进程资源占用情况,linux系统性能分析工具

用法

top -hv | -abcHimMsS -d delay -n iterations -p pid [, pid ...]

常用选项

选项 用途
-a 进程列表根据内存占用大小排序
-b 以batch模式运行
-c 显示完整命令名或者不显示,每次执行跟上一次执行记录的状态相反
-d ss.tt (seconds.tenths) 设置结果刷新间隔,默认是3秒
-h, -v 显示命令版本和用法
-H 显示进程所有线程信息和显示单个进程切换,每次执行跟上一次执行记录的状态相反
-i 显示或者不显示空闲的进程
-m VIRT/USED之前显示切换. Reports USED (sum of process rss and swap total count) instead of VIRT
-M 显示内存大小单位
-n number 设置刷新次数,默认为一直刷新
-p 监控指定的进程列表,最多20个,语法如下:-pN1 -pN2 ... or -pN1, N2 [,...]
-s 安全模式运行
-S Cumulative time mode切换
-u 监控指定的用户进程,语法格式:-u somebody
-U -U somebody,This matches real, effective, saved, and filesystem UIDs.

头字段说明

字段 含义
PID 进程id
PPID 父进程id
RUSER Real User Name
UID The effective user ID
USER The effective user name
GROUP The effective group name
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 or output. However, a task need not be associated with a terminal, in which case you’ll see ’?’ displayed.
PR 任务的优先级
NI Nice value
P Last used CPU (SMP)
%CPU CPU usage
TIME CPU Time
TIME+ CPU Time, hundredths
%MEM Memory usage (RES)
VIRT Virtual Image (kb)
SWAP Swapped size (kb)
RES Resident size (kb)
CODE Code size (kb)
DATA Data+Stack size (kb)
SHR Shared Mem size (kb)
nFLT Page Fault count
nDRT Dirty Pages count
S Process Status
Command Command line or Program name
WCHAN Sleeping in Function
Flags Task Flags

SELECTING and ORDERING Columns

After pressing the interactive commands ’f’ (Fields select) or ´o’ (Order fields) you will be shown a screen containing the current fields string followed by names and descriptions for all fields.

SUMMARY Area Fields

The summary area fields describing CPU statistics are abbreviated.

field1 说明
us user mode
sy system mode
ni low priority user mode (nice)
id idle task
wa I/O waiting
hi servicing IRQs
si servicing soft IRQs
st steal (time given to other DomU instances)

交互命令

The commands shown with an asterisk (’*’) are not available in ’Secure mode’, nor will they be shown on the level-1 help screen.

GLOBAL Commands

命令 含义 说明
or 刷新显示 ##
´?´ or ´h´ 显示命令帮助信息 ##
´=´ Exit Task Limits Removes restrictions on which tasks are shown. This command will reverse any ’i’ (idle tasks) and ’n’ (max tasks) commands that might be active. It also provides for an ’exit’ from PID monitoring. See the ’-p’ command-line option for a discussion of PID monitoring. When operating in alternate-display mode this command has a slightly broader meaning.
´A´ Alternate Display Mode toggle This command will switch between full-screen mode and alternate-display mode. See topic 4. ALTERNATE-DISPLAY Mode and the ’G’ interactive command for insight into ´current’ windows and field groups.
´B´ Bold Disable/Enable toggle This command will influence use of the ’bold’ terminfo capability and alters both the summary area and task area for the ´current’ window. While it is intended primarily for use with dumb terminals, it can be applied anytime.
* ´d´ or ´s´ Change Delay Time interval You will be prompted to enter the delay time, in seconds, between display updates. Fractional seconds are honored, but a negative number is not allowed. Entering 0 causes (nearly) continuous updates, with an unsatisfactory display as the system and tty driver try to keep up with top’s demands. The delay value is inversely proportional to system loading, so set it with care. If at any time you wish to know the current delay time, simply ask for help and view the system summary on the second line.
´G´ Choose Another Window/Field Group You will be prompted to enter a number between 1 and 4 designating the window/field group which should be made the ´current’ window. You will soon grow comfortable with these 4 windows, especially after experimenting with alternate-display mode.
´I´ Irix/Solaris Mode toggle When operating in ’Solaris mode’ (’I’ toggled Off), a task’s cpu usage will be divided by the total number of CPUs. After issuing this command, you’ll be informed of the new state of this toggle.
´u´ select a user You will be prompted for a UID or username. Only processes belonging to the selected user will be displayed. This option matches on the effective UID.
´U´ select a user You will be prompted for a UID or username. Only processes belonging to the selected user will be displayed. This option matches on the real, effective, saved, and filesystem UID.
* ´k´ Kill a task You will be prompted for a PID and then the signal to send. The default signal, as reflected in the prompt, is SIGTERM. However, you can send any signal, via number or name. If you wish to abort the kill process, do one of the following depending on your progress: 1) at the pid prompt, just press 2) at the signal prompt, type 0
´q´ Quit ##
* ´r´ Renice a Task You will be prompted for a PID and then the value to nice it to. Entering a positive value will cause a process to lose priority. Conversely, a negative value will cause a process to be viewed more favorably by the kernel.
´W´ Write the Configuration File This will save all of your options and toggles plus the current display mode and delay time. By issuing this command just before quitting top, you will be able restart later in exactly that same state.
´Z´ Change Color Mapping This key will take you to a separate screen where you can change the colors for the ´current’ window, or for all windows. For details regarding this interactive command see topic 3d. COLOR Mapping.

SUMMARY Area Commands

The summary area interactive commands are always available in both full-screen mode and alternate-display mode. They affect the beginning lines of your display and will determine the position of messages and prompts.

命令 含义 说明
´l´ Toggle Load Average/Uptime -- On/Off This is also the line containing the program name (possibly an alias) when operating in full-screen mode or the ´current’ window name when operating in alternate-display mode.
´m´ Toggle Memory/Swap Usage -- On/Off This command affects two summary area lines.
´t´ Toggle Task/Cpu States -- On/Off This command affects from 2 to many summary area lines, depending on the state of the ’1’ toggle and whether or not top is running under true SMP.
´1´ Toggle Single/Separate Cpu States -- On/Off This command affects how the ’t’ command’s Cpu States portion is shown. Although this toggle exists primarily to serve massively-parallel SMP machines, it is not restricted to solely SMP environments.

TASK Area Commands

The task area interactive commands are always available in full-screen mode.

The task area interactive commands are never available in alternate-display mode if the ´current’ window’s task display has been toggled Off (see topic 4. ALTERNATE-DISPLAY Mode).

命令 含义 说明
´b´ Bold/Reverse toggle This command will impact how the ’x’ and ’y’ toggles are displayed. Further, it will only be available when at least one of those toggles is On.
´x´ Column Highlight toggle Changes highlighting for the current sort field. You probably don’t need a constant visual reminder of the sort field and top hopes that you always run with ’column highlight’ Off, due to the cost in path-length. If you forget which field is being sorted this command can serve as a quick visual reminder.
´y´ Row Highlight toggle Changes highlighting for "running" tasks. For additional insight into this task state, see topic 2a. DESCRIPTIONS of Fields, Process Status. Use of this provision provides important insight into your system’s health. The only costs will be a few additional tty escape sequences.
´z´ Color/Monochrome toggle Switches the ´current’ window between your last used color scheme and the older form of black-on-white or white-on-black. This command will alter both the summary area and task area but does not affect the state of the ’x’, ’y’ or ’b’ toggles.
´c´ Command Line/Program Name toggle This command will be honored whether or not the ’Command’ column is currently visible. Later, should that field come into view, the change you applied will be seen.
´f´ and ´o´ Fields select or Order fields These keys display separate screens where you can change which fields are displayed and their order. For additional information on these interactive commands see topic 2b. SELECTING and ORDERING Columns.
´H´ Threads toggle When this toggle is On, all individual threads will be displayed. Otherwise, top displays a summation of all threads in a process.
´S´ Cumulative Time Mode toggle When ’Cumulative mode’ is On, each process is listed with the cpu time that it and its dead children have used. When Off, programs that fork into many separate tasks will appear less demanding. For programs like ’init’ or a shell this is appropriate but for others, like compilers, perhaps not. Experiment with two task windows sharing the same sort field but with different ’S’ states and see which representation you prefer. After issuing this command, you’ll be informed of the new state of this toggle. If you wish to know in advance whether or not ’Cumulative mode’ is in effect, simply ask for help and view the window summary on the second line.
´u´ Show Specific User Only You will be prompted to enter the name of the user to display. Thereafter, in that task window only matching User ID’s will be shown, or possibly no tasks will be shown. Later, if you wish to monitor all tasks again, reissue this command but just press at the prompt, without providing a name.
´i´ Idle Processes toggle Displays all tasks or just active tasks. When this toggle is Off, idled or zombied processes will not be displayed. If this command is applied to the last task display when in alternate-display mode, then it will not affect the window’s size, as all prior task displays will have already been painted.
´n´ or ´#´ Set Maximum Tasks You will be prompted to enter the number of tasks to display. The lessor of your number and available screen rows will be used.
´<´ Move Sort Field Left Moves the sort column to the left unless the current sort field is the first field being displayed.
´>´ Move Sort Field Right Moves the sort column to the right unless the current sort field is the last field being displayed.
´F´ or ´O´ Select Sort Field These keys display a separate screen where you can change which field is used as the sort column. If a field is selected which was not previously being displayed, it will be forced On when you return to the top display. However, depending upon your screen width and the order of your fields, this sort field may not be displayable.
´R´ Reverse/Normal Sort Field toggle Using this interactive command you can alternate between high-to-low and low-to-high sorts.

参考资料

【1】man top

转载于:https://www.cnblogs.com/wadeyu/p/9335094.html

N天学习一个Linux命令之top相关推荐

  1. N天学习一个Linux命令之帮助命令:man

    前言 工作中每天都在使用常用的命令和非常用的命令,忘记了用法或者参数,都会bing一下,然后如此循环.一直没有真正的系统的深入的去了解命令的用法,我决定打破它.以前看到有人,每天学习一个linux命令 ...

  2. linux set命令例子,学习一个 Linux 命令:declare/typeset 命令

    原标题:学习一个 Linux 命令:declare/typeset 命令 1 功能简介 declare(别名 typeset)属 Shell 内建命令,用于申明 Shell 变量并设置变量属性,或查看 ...

  3. top刷新间隔_每天一个linux命令:top命令

    top命令是Linux下常用的性能分析工具,能够实时显示系统中各个进程的资源占用状况,类似于Windows的任务管理器.下面详细介绍它的使用方法.top是一个动态显示过程,即可以通过用户按键来不断刷新 ...

  4. 学习一个 Linux 命令:sort 命令

    今天来给大家介绍一下linux的sort命令 1.命令简介 以行为单位对文本文件的内容进行排序,将结果显示在标准输出,比较原则是从行首字符向后,依次按 ASCII 码值进行比较,最后按升序输出.如果 ...

  5. 学习一个 Linux 命令:pstree

    linux在工作中用的越来越多,接下来为大家介绍一下比较常用的命令pstree的使用方法 命令简介 pstree 命令以树状图的方式展现进程之间的派生关系. [root@centos7 ~]# pst ...

  6. 学习一个 Linux 命令:shutdown 命令

    今天来给大家介绍一下linux的命令 shutdown 1.功能 shutdown 指令可以关闭所有程序,并依用户的需要,进行重启或关机操作. 使用 shutdown 命令时,在系统关机前,可以通知所 ...

  7. 学习一个 Linux 命令:realpath 命令

    转自:恋猫大鲤鱼链接:https://dablelv.blog.csdn.net/article/details/90710645 1.命令简介 realpath 用于获取指定目录或文件的绝对路径. ...

  8. N天学习一个linux命令之rsync

    用途 主要用于本地和远程主机同步文件 特性 1 使用增量传输算法(delta-transfer algorithm) 2 支持ssh,rsync协议 3 可以用于本地同步文件 4 本地和远程主机都需要 ...

  9. N天学习一个linux命令之lsof

    用途 列出进程已打开的文件,文件可以是常规文件,特殊文件,目录,socket,设备,共享库等.如果不带参数,lsof显示所有进程打开的所有文件. 用法 lsof [ -?abChlnNOPRtUvVX ...

最新文章

  1. 波士顿动力的机器人会开门了,中国还要奋力追赶
  2. Kubernetes(1) kubectl 入门
  3. 最明的int和Integer的区别
  4. 程序实现php文件上传,PHP实例:实现文件上传的程序源码_php
  5. 编程语言里函数方法类型检查的重要性
  6. 很好的理解遗传算法的样例
  7. 【Java教程系列】JavaSE核心知识点总结
  8. pandas python groupby_python – pandas groupby方法实际上是如何工作的?
  9. Excel如何快速制作文件目录
  10. ADNI数据集相关概念初步整理
  11. arduino tft 方向_Arduino2.4英寸TFT显示屏的演示
  12. 北京农学院计算机调剂,2020北京农学院植物科学技术学院招收硕士研究生调剂...
  13. 鲁迅研究(海南大学)
  14. Redis ZADD命令
  15. 抱怨一下项立刚先生和他的飞象网的博客
  16. CF1131F Asya And Kittens
  17. 解决方案|电力行业应如何应对数字化转型危机
  18. 高仿精仿好123网站导航源码完整最新版
  19. 多个输入框失焦事件触发异常问题解决
  20. 我为什么反对寄希望于内部培训提升员工技能的方法?

热门文章

  1. 爬虫怎样绕过验证码?
  2. 商简智能计划与排程SPS在汽车零部件行业的应用
  3. DC-4靶机渗透测试
  4. 实验六:555定时器
  5. S32K144之SDK版:FLASH(内部模拟EEPROM)模块应用
  6. 因子分析模型(清风建模学习笔记)
  7. RAC 环境修改私有网卡步骤
  8. 未找到重要体积,且场景太大,自动合成的体积无法产生良好的效果。请添加一个紧密包裹的lightmass重要体积来优化场景质量及光照构建时间。
  9. matlab函数fftshift,matlab中fft算法_matlab中fftshift函数_matlab中fft函数的用法(2)
  10. 上海银联chinapay支付接口实现详解