renamed: 10 Linux Platforms Meant For Embedded Systems.md -> 201406/10 Linux Platforms Meant For Embedded Systems.md renamed: 20140527 4MLinux 9.0 Beta Is a 55 MB Operating System That Has It All.md -> 201406/20140527 4MLinux 9.0 Beta Is a 55 MB Operating System That Has It All.md renamed: 20140527 A Complete Historical Timeline of Linux Evolution.md -> 201406/20140527 A Complete Historical Timeline of Linux Evolution.md renamed: 20140528 Setup Backup Server Using Bacula And Webmin On Ubuntu 14.04.md -> 201406/20140528 Setup Backup Server Using Bacula And Webmin On Ubuntu 14.04.md renamed: 20140528 Why We Shouldn't Accept Bad Linux Ports.md -> 201406/20140528 Why We Shouldn't Accept Bad Linux Ports.md renamed: 20140529 Add Windows Like Bottom Taskbar In Ubuntu Unity 14.04.md -> 201406/20140529 Add Windows Like Bottom Taskbar In Ubuntu Unity 14.04.md renamed: 20140529 Command Line Tuesdays--The Introductory.md -> 201406/20140529 Command Line Tuesdays--The Introductory.md renamed: 20140529 How To Share Disks In VirtualBox Between Linux Guest OS.md -> 201406/20140529 How To Share Disks In VirtualBox Between Linux Guest OS.md renamed: 20140529 Install RainLoop Webmail (A Web Based Email Client) using 'Nginx and Apache' in Arch Linux.md -> 201406/20140529 Install RainLoop Webmail (A Web Based Email Client) using 'Nginx and Apache' in Arch Linux.md renamed: 20140529 What is a good terminal emulator on Linux.md -> 201406/20140529 What is a good terminal emulator on Linux.md renamed: 20140529 Why No Flash Support for Linux Is Good for Open Source.md -> 201406/20140529 Why No Flash Support for Linux Is Good for Open Source.md renamed: 20140530 Fix 'Cannot Add PPA' Error In Ubuntu 14.04 and Linux Mint.md -> 201406/20140530 Fix 'Cannot Add PPA' Error In Ubuntu 14.04 and Linux Mint.md renamed: 20140530 How To Install Linux On A MacBook Pro Retina.md -> 201406/20140530 How To Install Linux On A MacBook Pro Retina.md renamed: 20140530 Linux script command--A recorder inside your Terminal.md -> 201406/20140530 Linux script command--A recorder inside your Terminal.md renamed: 20140603 App Grid Is A Superior Ubuntu Software Center Alternative.md -> 201406/20140603 App Grid Is A Superior Ubuntu Software Center Alternative.md renamed: 20140603 Linux Foundation to donate portion of membership fees to Code.org.md -> 201406/20140603 Linux Foundation to donate portion of membership fees to Code.org.md renamed: 20140603 Write your first Linux Kernel module.md -> 201406/20140603 Write your first Linux Kernel module.md renamed: 20140604 Command line secrets.md -> 201406/20140604 Command line secrets.md renamed: 20140604 Setup Virtual Hosts In Apache On Ubuntu 14.04 LTS.md -> 201406/20140604 Setup Virtual Hosts In Apache On Ubuntu 14.04 LTS.md renamed: 20140607 Cup 2014 Brazil--Watch FIFA World Cup 2014 Competition in Your Linux Desktop.md -> 201406/20140607 Cup 2014 Brazil--Watch FIFA World Cup 2014 Competition in Your Linux Desktop.md renamed: 20140607 How To Extract Images From Videos Using ffmpeg.md -> 201406/20140607 How To Extract Images From Videos Using ffmpeg.md renamed: 20140607 How To Install iCup 2014 In Linux.md -> 201406/20140607 How To Install iCup 2014 In Linux.md renamed: 20140607 Linux--Bash Delete All Files In Directory Except Few.md -> 201406/20140607 Linux--Bash Delete All Files In Directory Except Few.md renamed: 20140607 New OpenSSL breach is no Heartbleed-but needs to be taken seriously.md -> 201406/20140607 New OpenSSL breach is no Heartbleed-but needs to be taken seriously.md renamed: 20140607 Nuvola Player 2.4.0 Released -- A Online Cloud Music Player for Linux.md -> 201406/20140607 Nuvola Player 2.4.0 Released -- A Online Cloud Music Player for Linux.md renamed: 20140607 Practical Interview Questions and Answers on Linux Shell Scripting.md -> 201406/20140607 Practical Interview Questions and Answers on Linux Shell Scripting.md renamed: 20140607 Steam Hits The Big 500 For Linux Games.md -> 201406/20140607 Steam Hits The Big 500 For Linux Games.md renamed: 20140607 Ubuntu One Formally Shuts Down.md -> 201406/20140607 Ubuntu One Formally Shuts Down.md renamed: 20140609 How To Know If Your System Has USB 3.0 Port In Linux [Quick Tip].md -> 201406/20140609 How To Know If Your System Has USB 3.0 Port In Linux [Quick Tip].md renamed: 20140609 Open Source LDAP Solutions.md -> 201406/20140609 Open Source LDAP Solutions.md renamed: "20140609 OpenELEC 4.0.4 \347\216\260\345\267\262\345\217\221\345\270\203, \345\237\272\344\272\216 XBMC 13.1 \342\200\234Gotham\342\200\235.md" -> "201406/20140609 OpenELEC 4.0.4 \347\216\260\345\267\262\345\217\221\345\270\203, \345\237\272\344\272\216 XBMC 13.1 \342\200\234Gotham\342\200\235.md" renamed: 20140610 How to set up Internet connection sharing with iptables on Linux.md -> 201406/20140610 How to set up Internet connection sharing with iptables on Linux.md renamed: 20140610 IPFire 2.13 Core 78 Linux Firewall OS Receives OpenSSL Fixes.md -> 201406/20140610 IPFire 2.13 Core 78 Linux Firewall OS Receives OpenSSL Fixes.md renamed: 20140610 Open Source SDN Project OpenDaylight Adds New Members.md -> 201406/20140610 Open Source SDN Project OpenDaylight Adds New Members.md renamed: 20140610 Top 7 Desktop Environment For Linux.md -> 201406/20140610 Top 7 Desktop Environment For Linux.md renamed: 20140611 HTG Explains--What' s the Difference Between Linux and BSD.md -> 201406/20140611 HTG Explains--What' s the Difference Between Linux and BSD.md renamed: 20140611 How to Prevent Other Users From Accessing Your Home Directory in Ubuntu 14.04.md -> 201406/20140611 How to Prevent Other Users From Accessing Your Home Directory in Ubuntu 14.04.md renamed: 20140612 Command Line Tuesdays--Part One.md -> 201406/20140612 Command Line Tuesdays--Part One.md renamed: 20140612 Dpkg Vulnerabilities Closed in Ubuntu 14.04.md -> 201406/20140612 Dpkg Vulnerabilities Closed in Ubuntu 14.04.md renamed: 20140616 How To Install Numix Icon Theme In Fedora 20.md -> 201406/20140616 How To Install Numix Icon Theme In Fedora 20.md renamed: 20140616 Ubuntu Desktop Next 14.10 Images Available to Download.md -> 201406/20140616 Ubuntu Desktop Next 14.10 Images Available to Download.md renamed: 20140616 Ubuntu for Phones Activated on 10,000 Devices.md -> 201406/20140616 Ubuntu for Phones Activated on 10,000 Devices.md renamed: 20140617 14 Apps To Boost Ubuntu.md -> 201406/20140617 14 Apps To Boost Ubuntu.md renamed: 20140619 Improve Battery Life with Laptop Mode Tools 1.65.md -> 201406/20140619 Improve Battery Life with Laptop Mode Tools 1.65.md renamed: 20140619 Red Hat to Acquire eNovance, Focus Together on OpenStack.md -> 201406/20140619 Red Hat to Acquire eNovance, Focus Together on OpenStack.md renamed: 20140620 Celebrating 30 Years of X.md -> 201406/20140620 Celebrating 30 Years of X.md renamed: 20140620 ENCRYPT DNS TRAFFIC IN LINUX WITH DNSCRYPT (VIA OPENDNS).md -> 201406/20140620 ENCRYPT DNS TRAFFIC IN LINUX WITH DNSCRYPT (VIA OPENDNS).md renamed: 20140620 How to enable testing and unstable repository on Debian.md -> 201406/20140620 How to enable testing and unstable repository on Debian.md renamed: 20140625 Canonical Debuts 'Orange Box' for Ubuntu OpenStack Cloud Demos.md -> 201406/20140625 Canonical Debuts 'Orange Box' for Ubuntu OpenStack Cloud Demos.md renamed: 8 examples of findmnt command to check mounted file systems on Linux.md -> 201406/8 examples of findmnt command to check mounted file systems on Linux.md renamed: Bash Getopts--Scripts with Command Line Options.md -> 201406/Bash Getopts--Scripts with Command Line Options.md renamed: Collectl--An Advanced All-in-One Performance Monitoring Tool for Linux.md -> 201406/Collectl--An Advanced All-in-One Performance Monitoring Tool for Linux.md renamed: Fix Adobe Flash Player Issue In Chromium In Ubuntu 14.04.md -> 201406/Fix Adobe Flash Player Issue In Chromium In Ubuntu 14.04.md renamed: Guide To Install Ubuntu 14.04 In Dual Boot Mode With Windows 8 Or 8.1 UEFI.md -> 201406/Guide To Install Ubuntu 14.04 In Dual Boot Mode With Windows 8 Or 8.1 UEFI.md renamed: How To Install 'California' Calendar App in Ubuntu 14.04.md -> 201406/How To Install 'California' Calendar App in Ubuntu 14.04.md renamed: How To Remove Drive Icons From Unity Launcher In Ubuntu 14.04 [Beginner Tips].md -> 201406/How To Remove Drive Icons From Unity Launcher In Ubuntu 14.04 [Beginner Tips].md renamed: How to Install Windows 8.1 and Ubuntu 14.04 LTS on the Same Computer.md -> 201406/How to Install Windows 8.1 and Ubuntu 14.04 LTS on the Same Computer.md renamed: How to download webcomics from the command line on Linux.md -> 201406/How to download webcomics from the command line on Linux.md renamed: How to launch applications differently with Gnome-Pie on Linux desktop.md -> 201406/How to launch applications differently with Gnome-Pie on Linux desktop.md renamed: How to manage Linux containers with Docker on Ubuntu.md -> 201406/How to manage Linux containers with Docker on Ubuntu.md renamed: How to manage ip addresses and subnets with phpIPAM.md -> 201406/How to manage ip addresses and subnets with phpIPAM.md renamed: How to manage passwords from the command line on Linux.md -> 201406/How to manage passwords from the command line on Linux.md renamed: How to monitor Nginx web server from the command line in real time.md -> 201406/How to monitor Nginx web server from the command line in real time.md renamed: How to set up a web-based lightweight system monitor on Linux.md -> 201406/How to set up a web-based lightweight system monitor on Linux.md renamed: How to take a screenshot from the command line on Linux.md -> 201406/How to take a screenshot from the command line on Linux.md renamed: How to take full length screenshots of websites via terminal.md -> 201406/How to take full length screenshots of websites via terminal.md renamed: How to use LVM in Linux.md -> 201406/How to use LVM in Linux.md renamed: How to verify DDOS attack with netstat command on Linux Terminal.md -> 201406/How to verify DDOS attack with netstat command on Linux Terminal.md renamed: Install SoundCloud In Ubuntu 14.04.md -> 201406/Install SoundCloud In Ubuntu 14.04.md renamed: Linux Pros' Top Command Line Secrets.md -> 201406/Linux Pros' Top Command Line Secrets.md renamed: Linux Terminal--Dstat monitoring tools.md -> 201406/Linux Terminal--Dstat monitoring tools.md renamed: Making Linux Feel at Home.md -> 201406/Making Linux Feel at Home.md renamed: Open Source's Cult Of Personality Is Dying--Thankfully.md -> 201406/Open Source's Cult Of Personality Is Dying--Thankfully.md renamed: Pros' Secrets and Red Hat 7 and PCLinuxOS 2014.05 Reviews.md -> 201406/Pros' Secrets and Red Hat 7 and PCLinuxOS 2014.05 Reviews.md renamed: Start Practising Linux ip command and Avoid the Habit of Using ifconfig.md -> 201406/Start Practising Linux ip command and Avoid the Habit of Using ifconfig.md renamed: TechView--Linus Torvalds Inventor of Linux.md -> 201406/TechView--Linus Torvalds Inventor of Linux.md renamed: Turn Off Bluetooth By Default In Ubuntu 14.04 [Quick Tip].md -> 201406/Turn Off Bluetooth By Default In Ubuntu 14.04 [Quick Tip].md renamed: Ubuntu Linux Community Manager Jono Bacon Leaves Canonical.md -> 201406/Ubuntu Linux Community Manager Jono Bacon Leaves Canonical.md renamed: What Heartbleed Teaches Us--Be An Open Source Contributor, Not Just A User.md -> 201406/What Heartbleed Teaches Us--Be An Open Source Contributor, Not Just A User.md renamed: Why htop Command Compete Linux top Command.md -> 201406/Why htop Command Compete Linux top Command.md
4.8 KiB
为什么 Linux 的 htop 命令完胜 top 命令
在 Linux 系统中,top 命令用来显示系统中正在运行的进程的实时状态,它显示了一些非常有用的信息,比如 CPU 利用情况、内存消耗情况,以及每个进程情况等。但是,你知道吗?还有另外一个命令行工具 'htop',它与传统的 top 命令功能一样,但它有更加强大的功能及能显示更多的信息。这篇文章,我们会用实例来讨论这个 'htop' 命令。
Linux 中的 htop 命令
下面是从 htop 的手册页摘抄下来的相关描述:
它类似于 top 命令,但可以让你在垂直和水平方向上滚动,所以你可以看到系统上运行的所有进程,以及他们完整的命令行。
可以不用输入进程的 PID 就可以对此进程进行相关的操作 (killing, renicing)。
首先明白它的输出
htop 命令以直观的格式来显示信息。下面是 HTOP 的输出快照:
如果你观察窗口的左上角部分,你会看到显示的是 CPU 负载、内存消耗及交换空间的实时信息,右上角包含的是任务、线程、平均负载及系统运行时间的信息。
平均负载部分提供了三个数字,这仅仅表示的是过去的5分钟、10分钟和15分钟系统的平均负载而已,在单核的系统中,平均负载为1表示的是百分之百的 CPU 利用率。最后,运行时间 (uptime)标示的数字是从系统启动起到当前的运行总时间。
下面,我们将用例子来进一步讨论这个命令。
1. 用 F2 键编辑配置
htop 命令提供了许多自定义选项,你所要做的就是从主窗口中按下 F2 键。
下面所示的是可用的自定义选项:
只需使用箭头键选择和更改特定的设置。
2. 通过 F9 键发送信号
htop 命令可以让你很容易地在 htop 窗口内给一个进程发送任意的信号。按下 F9 键即可。
如你所见,窗口的左边部分列出的是所有可用的信号,右边部分列出的是进程。只要选中信号,并选择一个进程,然后按下 enter 键,选中的信号就会发送到此进程。
3. 显示进程的树状视图
htop 命令也提供了进程的树状视图查看功能。按下 F5 键切换。
下面是 htop 显示树形视图信息的例子:
要退出树状视图模式,请再一次按下 F5 键。
4. 通过 F3 键搜索进程
htop 命令提供了易用的方式来搜索进程。按下 F3 键,一个文本框就会出现在窗口底部。
下面是例子:
如您所见,一条名为‘搜索’的文本提示框出现在窗口底部,您可以在这儿输入进程的名字然后回车搜索。如果找到,它会在列出的进程列表里高亮选中此进程。
5. 通过空格键来设置颜色标注进程条目
在系统中运行着的实时进程视图中,要追踪某个进程是个大问题。因为整个列表在不停的刷新着,进程的排列顺序也在变动着。为了这个问题, htop 提供了一个很简单的解决方案:颜色标注。是的,你可以标注一个进程条目,它会以不同的颜色显示,因此要追踪它就变得容易了。
要标注某个进程条目,需要做的就是选中此条目,然后按下‘空格’键。例如,在下面的截图示例中,我已经颜色标注了三个进程条目:
所以通过此方法,你就能很轻松地追踪想查看的进程。
6. 命令行选项
除了上面介绍的一些热键,htop 还提供了很有用的命令行选项。下面是其中一部分:
- -s 选项 : 按指定的列排序。例如,htop -s PID 命令会按 PID 列的大小排序来显示。
- -u 选项 : 显示指定的用户的进程信息列表。例如,htop -u himanshu 命令会只显示出用户名为 himanshu 的相关进程。
- -d 选项 : 设置刷新的延迟时间。例如,htop -d 100 命令会使输出在1秒后才会刷新(参数 -d 的单位是10微秒)。
via: http://linoxide.com/linux-command/linux-htop-command/
译者:runningwater 校对:Caroline