N天学习一个Linux命令之top
用途
查看机器负载以及进程资源占用情况,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
N天学习一个Linux命令之top的更多相关文章
- 2018/03/11 每日一个Linux命令 之 top
每日一个Linux命令 之 top 今天在公司测试服务器上跑了一个我写的功能[本地测试过的],但是不知道怎么跑了个无限死循环出来,一个文件的体积在不停的变大,如果不管的话这能行? 上去一看,PHP ...
- N天学习一个Linux命令之帮助命令:man
前言 工作中每天都在使用常用的命令和非常用的命令,忘记了用法或者参数,都会bing一下,然后如此循环.一直没有真正的系统的深入的去了解命令的用法,我决定打破它.以前看到有人,每天学习一个linux命令 ...
- 每天一个linux命令之top
每天一个linux命令之top 转 https://www.linuxprobe.com/chapter-02.html 在图2-6中,top命令执行结果的前5行为系统整体的统计信息,其所代表的含义 ...
- N天学习一个Linux命令之free
用途 查看系统内存(物理/虚拟/缓存/共享)使用情况 用法 free [-b | -k | -m | -g | -h] [-o] [-s delay ] [-c count ] [-a] [-t] [ ...
- N天学习一个linux命令之ping
用途 检测主机是否可到达,也就是说,目标主机是否可以联网,还可以用于检测网速.通过发送ICMP ECHO_REQUEST数据包检测. 用法 ping [options] destination 常用选 ...
- N天学习一个linux命令之kill
用途 用于终止进程 用法 kill [-s signal|-p] [--] pid... kill -l [signal] 说明 1.默认发送信号15(请求终止进程,程序可以捕获,操作系统会杀死没有对 ...
- N天学习一个linux命令之du
用途 统计文件或者目录占用硬盘空间大小 用法 du [OPTION] [FILE]du [OPTION] --files0-from=F 常用参数 -a, --all统计所有文件,不仅仅是目录 -b, ...
- N天学习一个linux命令之scp
用途 通过ssh通道,不同主机之间复制文件 用法 scp [options] [user@host:]file1 [user2@host2:]file2 常用参数 -1使用 ssh 1协议 -2使用s ...
- 每天学习一个Linux命令-目录
在工作中总会零零散散使用到各种Linux命令,从今天开始详细的学习一下linux常用命令,坚持每天一个命令,学习的主要参考资料为: 1.竹子-博客(https://www.cnblogs.com/pe ...
随机推荐
- maven的pom.xml文件错误
来自:http://www.cnblogs.com/shihujiang/p/3492864.html
- Bitmap与String之间的转换
/** * 将bitmap转换成base64字符串 * * @param bitmap * @return base64 字符串 */ public String bitmaptoString(Bit ...
- [转]linux之at指令详解
转自:http://www.2cto.com/os/201409/336183.html 指令:at定时任务,指定一个时间执行一个任务,只能执行一次. 语法:# at [参数] [时间]at> ...
- python--11、数据库及SQL基础
常用命令记录 查看库中所有表的引擎 SHOW TABLE STATUS FROM `center_main_db`; 还有一个更简洁,查询cmol_system_db库所有表的存储引擎\ SELECT ...
- Javascript实现导航锚点滚动效果实例
本篇文章主要介绍了Javascript实现页面滚动时导航智能定位,具有一定的参考价值,感兴趣的小伙伴们可以参考一下 常见的开发页面中可能会有这么一个需求,页面中会有多个模块,每个模块对应一个导航,当页 ...
- html5——web字体
基本介绍 1.自定义网页特殊字体,无需考虑用户电脑上是否安装了此特殊字体,从此把特殊字体处理成图片的时代便成为了过去. 2.支持程度比较好,甚至IE低版本浏览器也能支持. 3.web字体的大小鉴定是字 ...
- Linq处理decimal字段汇总Sum()为NULL
xxxxxxxx.Sum(f => f.jifen).GetValueOrDefault(0)
- Style在Android中的继承关系
Style在Android中的继承关系 Android的Styles(样式)和Themes(主题)非常类似Web开发里的CSS,方便开发者将页面内容和布局呈现分开.Style和Theme在Androi ...
- python笔记之发送邮件
发送邮件前提:开启邮箱授权码 一.开启授权码(以163邮箱为例) 1.登录163邮箱,点击设置--POP3/SMTP/IMAP,出现设置界面 2. 开启SMTP服务且可以查询SMTP的host地址 ...
- Java多线程学习笔记(一)——多线程实现和安全问题
1. 线程.进程.多线程: 进程是正在执行的程序,线程是进程中的代码执行,多线程就是在一个进程中有多个线程同时执行不同的任务,就像QQ,既可以开视频,又可以同时打字聊天. 2.线程的特点: 1.运行任 ...