Linux top 命令

The Default Display 默认显示

You can start top by typing the following and hitting “Enter”:

你可以输入以下内容并按回车键开始:

top

The default display contains two areas of information: the summary area (or dashboard), and the task area (or process list). By default, top updates its display every three seconds—you’ll notice a slight flicker when it does.

默认显示包含两个信息区域: 摘要区域(或仪表板)和任务区域(或进程列表)。在默认情况下,top 每三秒钟更新一次显示ーー当它这样做时,你会注意到一个轻微的闪烁。

The first line of numbers on the dashboard includes the time, how long your computer has been running, the number of people logged in, and what the load average has been for the past one, five, and 15 minutes. The second line shows the number of tasks and their states: running, stopped, sleeping, or zombie.

仪表板上的第一行数字包括时间、计算机运行的时间、登录的人数以及过去1分钟、5分钟和15分钟的平均负载。第二行显示了任务的数量及其状态: 运行、停止、睡眠或僵尸。

The third line displays the following central processing unit (CPU) values:

第三行显示以下中央处理单元(CPU)值:

  • us: Amount of time the CPU spends executing processes for people in “user space.”
  • Us: CPU 为“用户空间”中的人执行进程所花费的时间
  • sy: Amount of time spent running system “kernel space” processes.
  • Sy: 运行系统“内核空间”进程所花费的时间。
  • ni: Amount of time spent executing processes with a manually set nice value.
  • Ni: 使用手动设置的 nice 值执行流程所花费的时间。
  • id: Amount of CPU idle time.
  • Id: CPU 空闲时间量。
  • wa: Amount of time the CPU spends waiting for I/O to complete.
  • Wa: CPU 等待 I/O 完成所花费的时间。
  • hi: Amount of time spent servicing hardware interrupts.
  • Hi: 维护硬件中断所花费的时间。
  • si: Amount of time spent servicing software interrupts.
  • Si: 维护软件中断所花费的时间。
  • st: Amount of time lost due to running virtual machines (“steal time”).
  • St: 由于运行虚拟机而损失的时间量(“偷取时间”)。

The fourth line shows the total amount (in kibibytes) of physical memory, and how much is free, used, and buffered or cached.

第四行显示了物理内存的总量(以千字节为单位) ,以及有多少是空闲的、使用的、缓冲的或缓存的。

The fifth line shows the total amount (also in kibibytes) of swap memory, and how much is free, used, and available. The latter includes memory that’s expected to be recoverable from caches.

第五行显示交换内存的总量(也是千字节) ,以及有多少是空闲的、使用的和可用的。后者包括预期可从缓存恢复的内存。

The column headings in the process list are as follows:

进程清单中的栏标题如下:

  • PID: Process ID.
  • 进程 ID。
  • USER: The owner of the process.
  • 用户: 进程的所有者。
  • PR: Process priority.
  • PR: 进程优先。
  • NI: The nice value of the process.
  • NI: 这个过程的 nice value。
  • VIRT: Amount of virtual memory used by the process.
  • VIRT: 进程使用的虚拟内存量。
  • RES: Amount of resident memory used by the process.
  • RES: 进程使用的驻留内存量。
  • SHR: Amount of shared memory used by the process.
  • SHR: 进程使用的共享内存量。
  • S: Status of the process. (See the list below for the values this field can take).
  • 进程的状态(请参阅下面的列表,了解该字段可以接受的值)。
  • %CPU: The share of CPU time used by the process since the last update.
  • % CPU: 自上次更新以来进程使用的 CPU 时间份额。
  • %MEM: The share of physical memory used.
  • % MEM: 所使用的物理内存的份额。
  • TIME+: Total CPU time used by the task in hundredths of a second.
  • TIME + : 任务使用的 CPU 总时间(百分之一秒)。
  • COMMAND: The command name or command line (name + options).
  • COMMAND: 命令名或命令行(名称 + 选项)。

Memory values are shown in kibibytes. The COMMAND column is off-screen, to the right—it didn’t fit in the image above, but we’ll see it shortly.

内存值以千字节为单位显示。COMMAND 列在屏幕的右边ーー它不适合上面的图像,但我们很快就会看到它。

The status of the process can be one of the following:

该进程的状态可以是下列情况之一:

  • D: Uninterruptible sleep
  • 不间断的睡眠
  • R: Running
  • 运行
  • S: Sleeping
  • 睡眠
  • T: Traced (stopped)
  • 追踪(停止)
  • Z: Zombie
  • 僵尸

Press Q to exit top.

按 Q 键退出顶部。

Scrolling the Display 滚动显示

You can press the Up or Down Arrows, Home, End, and Page Up or Down keys to move up and down and access all the processes.

您可以按向上或向下箭头、首页、结束和页向上或向下键来向上和向下移动并访问所有进程。

Press the Left or Right Arrow to move the process list sideways. This is useful to see any columns that don’t fit within the confines of the terminal window.

按“左箭头”或“右箭头”将进程列表向侧面移动。这对于查看任何不适合终端窗口范围的列很有用。

Changing the Numeric Units 更改数字单位

Let’s change the display units to sensible values. Press capital E to cycle through the units used to display memory values in these options: kibibytes, mebibytes, gibibytes, tebibytes, pebibytes, and exbibytes. The unit in use is the first item on lines four and five.

让我们将显示单元更改为可感知值。按下大写 E 来循环显示这些选项中用于显示内存值的单位: kibibyte、 mebibyte、 gibibyte、 tebibyte、 pebibyte 和 exbibyte。正在使用的单元是第四行和第五行中的第一个项目。

Press lowercase “e” to do the same thing for the values in the process list: kibibytes, mebibytes, gibibytes, tebibytes, and pebibytes.

按下小写“ e”对进程列表中的值执行同样的操作: kibibyte、 mebibyte、 gibibyte、 tebibyte 和 pebibyte。

We pressed E to set the dashboard memory units to gibibytes and “e” to set the process list memory units to mebibytes.

我们按下 E 键将仪表板内存单元设置为 gibibyte,按下“ e”键将进程列表内存单元设置为 mebibyte。

If you have a multi-core CPU, press 1 to change the display and see individual statistics for each CPU. There are four CPUs on our computer. We press 1 to see how hard each of them is working.

如果您有一个多核 CPU,请按1以更改显示并查看每个 CPU 的单独统计数据。我们的计算机上有四个 CPU。我们按1看看他们每个工作负载。

Of course, this takes up more screen real estate within the terminal window.

当然,这会在终端窗口中占用更多的屏幕空间。

You can press “t” to swap the CPU displays to simple ASCII graphs that show the percentage of usage for each CPU.

您可以按“ t”将 CPU 显示交换到简单的 ASCII 图表,这些图表显示每个 CPU 的使用百分比。

For each CPU, top displays three numbers and the graph. From left to right, the numbers are as follows:

对于每个 CPU,top 显示三个数字和图形。从左到右,数字如下:

  • The combined us and ni percentage (user space+tasks with nonstandard nice settings).
  • Us 和 ni 的合并百分比(用户空间 + 具有非标准漂亮设置的任务)。
  • The sy percentage (kernel space).
  • Sy 百分比(内核空间)。
  • The total (rounded to an integer value).
  • 合计(四舍五入为整数值)。

Press “t” again to change the graph display to solid block characters.

再次按“ t”将图形显示更改为实心块字符。

Press “t” once more to remove the CPU display and task summary line completely.

再次按“ t”可以完全删除 CPU 显示和任务摘要行。

Press “m” to cycle the memory and swap memory lines through different display options. The first press replaces the statistics with an ASCII graph.

按“ m”循环存储器并通过不同的显示选项交换存储器行。第一个按钮用 ASCII 图表替换统计信息。

Another press changes the graph to block characters.

再按一次将图形更改为块字符。

Press “m” once more to remove the CPU lines altogether.

再按一次“ m”,删除所有的 CPU 行。

If you want, you can see CPU and memory graphs at the same time. Just press “t” and “m” until you get the combination you want.

如果需要,可以同时看到 CPU 和内存图。按“ t”和“ m”直到你得到你想要的。

Color and Highlighting 色彩和高亮

You can press “z” to add color to the display.

您可以按“ z”为显示器添加颜色。

When you think of top, you probably don’t think of colored displays and ASCII graphs, but they’re built right in.

当你想到 top 的时候,你可能不会想到彩色显示器和 ASCII 图形,但是它们是内置的。

Press “y” to highlight running tasks in the process list. Pressing “x” highlights the column used to sort the process list. You can toggle between bold and reversed text highlighting by pressing “b.”

按“ y”以突出显示进程列表中正在运行的任务。按“ x”将突出显示用于对进程列表进行排序的列。你可以通过按“ b”在粗体和反向文本高亮之间切换

Sorting by Columns 按列排序

By default, the process list is sorted by the %CPU column. You can change the sort column by pressing the following:

默认情况下,进程列表按% CPU 列排序。您可以按下列键更改排序列:

  • P: The %CPU column.
  • P:% CPU 列。
  • M: The %MEM column.
  • M:% MEM 列。
  • N: The PID column.
  • N: PID 列。
  • T: The TIME+ column.
  • T: TIME + 列。

Only See Active Tasks 只查看活动任务

Press I to see only active tasks.

按 I 只能看到活动任务。

Tasks that haven’t consumed any CPU since the last update won’t be shown.

自上次更新以来未使用任何 CPU 的任务将不会显示。

参考:

How to Use the Linux top Command (and Understand Its Output)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值