mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-02-03 23:40:14 +08:00
commit
a0111a150f
@ -1,91 +0,0 @@
|
||||
(翻译中 by runningwater)
|
||||
Why htop Command Compete Linux top Command
|
||||
================================================================================
|
||||
The top command in Linux is used to display a real-time view of processes that are running in the system. It provides very useful information like CPU utilization, memory consumption, and more, related to every process. But, do you know there exists another command line utility ‘htop’ that provides more information and features when compared with the traditional top command. In this article, we will discuss the ‘htop’ command with examples.
|
||||
|
||||
### htop command in Linux ###
|
||||
|
||||
Here is an excerpt of htop’s description from its man page :
|
||||
|
||||
> It is similar to top, but allows you to scroll vertically and horizon‐
|
||||
> tally, so you can see all the processes running on the system, along
|
||||
> with their full command lines.
|
||||
>
|
||||
> Tasks related to processes (killing, renicing) can be done without
|
||||
> entering their PIDs.
|
||||
|
||||
### Understand its output first ###
|
||||
|
||||
The **htop command** displays information in a typical format. Here is a snapshot of htop’s output :
|
||||
|
||||
![htop](http://linoxide.com/wp-content/uploads/2014/01/htop.png)
|
||||
|
||||
If you take a look at the top-left part of the window, you’ll observe real-time information related to CPU load, RAM consumption , and swap. The top-right part contains information related to tasks, threads, load average and uptime.
|
||||
|
||||
The load average section provides three figures, which are nothing but load averages calculated for past 5, 10 and 15 minutes. For a single core system, a load average of 1 means 100 percent CPU utilization. And finally, the uptime depicts the time since the system has been up and running.
|
||||
|
||||
Now, lets discuss this command through some examples.
|
||||
|
||||
### 1. Edit settings using F2 key ###
|
||||
|
||||
The htop command provides many customization options, all you have to do is to press F2 from the main window.
|
||||
|
||||
Here are the customization options available :
|
||||
|
||||
![htop-settings](http://linoxide.com/wp-content/uploads/2014/01/htop-settings.png)
|
||||
|
||||
Just use the arrow keys to select and change a particular setting.
|
||||
|
||||
### 2. Send Signals Through F9 key ###
|
||||
|
||||
The htop command provides you with a way through which you can easily send any signal to a process from within the htop window. All you have to do is to press F9.
|
||||
|
||||
![signals](http://linoxide.com/wp-content/uploads/2014/01/signals.png)
|
||||
|
||||
As you can see, the left part of the window now lists all the available signals, while the right part lists the processes. Just select and signal, then select a process, and then press enter to send the signal to the process.
|
||||
|
||||
### 3. Get a tree view of the processes ###
|
||||
|
||||
The htop command also provides a tree view of the processes. All you have to do is to press F5.
|
||||
|
||||
Here is an example of htop displaying information in a tree view :
|
||||
|
||||
![treeView](http://linoxide.com/wp-content/uploads/2014/01/treeView.png)
|
||||
|
||||
To come out of tree view, press the F5 key again.
|
||||
|
||||
### 4. Search Processes Through F3 key ###
|
||||
|
||||
The htop command provides an easy way to search processes. All you have to do is to press F3 key and a text box will appear at the bottom of the window.
|
||||
|
||||
Here is an example :
|
||||
|
||||
![search](http://linoxide.com/wp-content/uploads/2014/01/search1.png)
|
||||
|
||||
As you can see, a text prompt ‘Search’ appears at the bottom of the window. You can type the name of the process here and press enter to search it. If the htop command is able to find it, it will select the entry of that process in its output.
|
||||
|
||||
### 5. Colour Tag An Entry Through Space Key ###
|
||||
|
||||
In real-time view of processes running in the system, one of the main problem is to follow a process. This is because the entries keep on refreshing, and their order keeps on changing. The htop command provides an easy solution to this problem: Colour tagging. Yes, you can colour tag an entry so that it is displayed in a different colour, and hence becomes easy to follow.
|
||||
|
||||
To colour tag an entry, all you have to do is to select the entry and press ‘space’ key. For example, in the screen-shot below, I have colour tagged three entries :
|
||||
|
||||
![color-tag](http://linoxide.com/wp-content/uploads/2014/01/color-tag.png)
|
||||
|
||||
So this way, you can easily follow the process(es) you desire.
|
||||
|
||||
### 6. Command line options ###
|
||||
|
||||
Apart from the hot keys explained till now, the htop command also provides useful command line options. Some of them are :
|
||||
|
||||
- **-s Option** : To sort a particular column. For example, htop -s PID will sort the PID column output.
|
||||
- **-u Option** : To display process information related to a particular user. For example, htop -u himanshu will display process information related to the user himanshu.
|
||||
- **-d option** : To introduce delay between updates. For example, htop -d 100 will make sure that htop output updates after 1 sec (as the argument to -d is considered to be in tenths of seconds).
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://linoxide.com/linux-command/linux-htop-command/
|
||||
|
||||
译者:[runningwater](https://github.com/runningwater) 校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
@ -0,0 +1,87 @@
|
||||
为什么 Linux 的 htop 命令优于 top 命令
|
||||
================================================================================
|
||||
在 Linux 系统中,top 命令用来显示系统中正在运行的进程的实时状态,它显示了像 CPU 利用情况、内存消耗情况,以及每个进程情况等十分有用的信息。你应该知道,与传统的 top 命令功能一样的,还存在另一个命令行工具 'htop',但它有更加强大的功能及能显示更多的信息。这篇文章,我们会用实例来讨论这个 'htop' 命令。
|
||||
|
||||
### Linux 中的 htop 命令 ###
|
||||
|
||||
下面是从 htop 的手册页摘抄下来的相关描述:
|
||||
|
||||
> 它类似于 top 命令,但可以让你在垂直和水平方向上滚动,所以你可以看到系统上运行的所有进程,以及他们完整的命令行。
|
||||
>
|
||||
> 可以不用输入进程的 PID 就可以对此进程进行相关的操作 (killing, renicing)。
|
||||
|
||||
### 首先明白它的输出 ###
|
||||
|
||||
**htop 命令**以典型的格式来显示信息。下面是 HTOP 的输出快照:
|
||||
|
||||
![htop](http://linoxide.com/wp-content/uploads/2014/01/htop.png)
|
||||
|
||||
如果你观察窗口的左上角部分,你会看到显示的是 CPU 负载、内存消耗及交换空间的实时信息,右上角包含的是任务、平均负载及系统运行时间的信息。
|
||||
|
||||
平均负载部分提供了三个数字,这仅仅表示的是过去的5分钟、10分钟和15分钟系统的平均负载而已,在单核的系统中,平均负载为1表示的是百分之百的 CPU 利用率。最后,运行时间 (uptime)标示的数字是从系统启动起到当前的运行总时间。
|
||||
|
||||
下面,我们将用例子来进一步讨论这个命令。
|
||||
|
||||
### 1. 用 F2 键编辑配置 ###
|
||||
|
||||
该 HTOP 命令提供了许多自定义选项,你所要做的就是从主窗口中按下 F2 键。
|
||||
|
||||
下面所示的是可用的自定义选项:
|
||||
|
||||
![htop-settings](http://linoxide.com/wp-content/uploads/2014/01/htop-settings.png)
|
||||
|
||||
只需使用箭头键选择和更改特定的设置。
|
||||
|
||||
### 2. 通过 F9 键发送信号 ###
|
||||
|
||||
HTOP 命令提供了某种功能,通过此功能您可以很容易地在 HTOP 窗口内给一个进程发送任意的信号。您需要做的就是按下 F9 键。
|
||||
|
||||
![signals](http://linoxide.com/wp-content/uploads/2014/01/signals.png)
|
||||
|
||||
如你所见,窗口的左边部分列出的是可用的信号,右边部分列出的是进程。只要选中信号,并选择一个进程,然后按下 enter 键,选中的信号就会发送到此进程。
|
||||
|
||||
### 3. 显示进程的树状视图 ###
|
||||
|
||||
HTOP 命令也提供了进程的树状视图查看功能。您需要做的就是按下 F5 键。
|
||||
|
||||
下面是 htop 显示树形视图信息的例子:
|
||||
|
||||
![treeView](http://linoxide.com/wp-content/uploads/2014/01/treeView.png)
|
||||
|
||||
要退出树状视图模式,请再一次按下 F5 键。
|
||||
|
||||
### 4. 通过 F3 键搜索进程 ###
|
||||
|
||||
HTOP 命令提供了易用的方式来搜索进程。您需要做就是按下 F3 键,一个文本框就会出现在窗口底部。
|
||||
|
||||
下面是例子:
|
||||
|
||||
![search](http://linoxide.com/wp-content/uploads/2014/01/search1.png)
|
||||
|
||||
如您所见,一条名为‘搜索’的文本提示框在窗口底部出现了,您可以在这儿输出进程的名字然后回车搜索。如果找到,它会在列出的进程列表里选中此进程。
|
||||
|
||||
### 5. 通过空格键来设置颜色标注进程条目 ###
|
||||
|
||||
在系统中运行着的实时进程视图中,要追踪某个进程是个大问题。因为整个列表在不停的刷新着,进程的排列顺序也在变动着。为了这个问题, HTOP 提供了一个很简单的解决方案:颜色标注。是的,你可以标注一个进程条目,它会以不同的颜色显示,因此要追踪它就变得容易了。
|
||||
|
||||
要标注某个进程条目,需要做的就是选中此条目,然后按下‘空格’键。例如,在下面的截图示例中,我已经颜色标注了三个进程条目:
|
||||
|
||||
![color-tag](http://linoxide.com/wp-content/uploads/2014/01/color-tag.png)
|
||||
|
||||
所以通过此种方法,你就能很轻松的追踪想查看的进程。
|
||||
|
||||
### 6. 命令行选项 ###
|
||||
|
||||
除了上面介绍的一些热键,htop 还提供了很有用的命令行选项。下面是其中一部分:
|
||||
|
||||
- **-s 选项** : 按指定的列排序。例如,**htop -s PID** 命令会按 PID 列的大小排序来显示。
|
||||
- **-u 选项** : 显示指定的用户的进程信息列表。例如,**htop -u himanshu** 命令会只显示出用户名为 himanshu 的相关进程。
|
||||
- **-d 选项** : 设置刷新的延迟时间。例如,**htop -d 100** 命令会使输出在1秒后才会刷新(参数 -d 可以考虑是十分之一秒的时间)。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://linoxide.com/linux-command/linux-htop-command/
|
||||
|
||||
译者:[runningwater](https://github.com/runningwater) 校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
Loading…
Reference in New Issue
Block a user