Tips and tricks for htop

微信扫一扫,分享到朋友圈

Tips and tricks for htop

If you’ve ever logged in to a Linux server to check what’s going on, you’re probably using htop, a text-based system monitoring tool for Unix based systems.

It runs on host Unix systems, including OS X, via Homebrew: brew install htop

htop running in abyobu session; hover over to view explanations.

Basic Usage

  1. Displays the CPU usage (each CPU core gets a line, my CPU was 4 hyper threads = 4 lines).
    For CPU: Green = user apps, red = kernel usage. For memory: blue = low priority; yellow = IRQ.
  2. Displays the amount of processes and threads, load average (1, 5, 15 mins) and the system uptime.
  3. Has the columns. How to add more is shown below.
  4. List item for each process (or thread, if enabled);
    1. PID is the process ID
    2. PRI (“Priority”) is -20 (highest), 19 (lowest)
    3. VIRT is total amount of memory that can be allocated (including virtual)
    4. RES (“Resident”) shows actual physical memory used, S (status) R = running, ? = idle
    5. CPU% is amount of total CPU usage
    6. TIME is how much total cpu time that process is using
  5. The process path and name. See below for shortcuts to display environment, etc.
  6. Menu items: mouse can be used in addition to F keys, if enabled.

Use the mouse

While htop is a text-mode application, on most terminals, you can actually use the mouse to select processes, press the menu keys and navigate the Setup menu.

Selecting one or more processes

With the SPACE key, you can select multiple processes. You can them kill them via F9 .

Other things to do with a selected process:

  • To view the environment variables of a specific process, just navigate to the process via the arrow keys and press E .
  • Set IO priority via I .
  • List open files with lsof with L .
  • Trace syscalls with S .
  • Toggle path with P .

Hide threads

Per default htop shows threads of non-system programs, but this can result in the list being very verbose (leading to a bunch of duplicate program names) and hard to navigate. To turn that off, simply go to Setup > Display Options and check off both “Hide kernel threads” and “Hide userland process threads”.

Alternatively, kernel and user threads can be toggled with K and H , respectively.

Add some more columns

Per default, htop doesn’t show all its information. To add more columns, go to Setup > Columns and choose some new ones. Which to choose? Here’s the ones I commonly use:

  • PERCENT_CPU, PERCENT_MEMORY – shows how much a program is using in percentages
  • IO_RATE – shows how much disk IO the process is using

Filter by users

To select and view a specific users’ processes, type U .

This entry was posted on Sunday, September 30th, 2018 at 20:28 and is filed underArticles. You can follow any responses to this entry through theRSS 2.0 feed. You can, ortrackback from your own site.

微信扫一扫,分享到朋友圈

Tips and tricks for htop

Micronaut Mastery: Running Code On Startup

上一篇

The FBI used a suspect’s face to unlock his iPhone in Ohio case

下一篇

你也可能喜欢

Tips and tricks for htop

长按储存图像,分享给朋友