Htop
Содержание:
COLOPHON top
This page is part of the htop (an interactive process viewer)
project. Information about the project can be found at
⟨http://hisham.hm/htop/⟩. If you have a bug report for this manual
page, see ⟨http://github.com/hishamhm/htop/issues⟩. This page was
obtained from the project's upstream Git repository
⟨https://github.com/hishamhm/htop⟩ on 2020-08-13. (At that time, the
date of the most recent commit that was found in the repository was
2019-02-10.) If you discover any rendering problems in this HTML
version of the page, or you believe there is a better or more up-to-
date source for the page, or you have corrections or improvements to
the information in this COLOPHON (which is not part of the original
manual page), send a mail to man-pages@man7.org
htop 2.2.0 2015 HTOP(1)
Pages that refer to this page:
proc(5),
procfs(5),
iotop(8)
Состояния процессора (ЦП)
Состояния процессора (ЦП).
Cpu(s): 1.1%us, 0.7%sy, 0.0%ni, 97.9%id, 0.2%wa, 0.0%hi, 0.2%si, 0.0%st
- us — (User CPU time) процент использования процессорного времени программами пользователей;
- sy — (System CPU time) процент использования процессорного времени процессами ядра Linux;
- ni — (Nice CPU time) процент использования процессорного времени программами с измененным приоритетом;
- id — простой процессора
- wa — (iowait) время, затраченное на завершение ввода/вывода (IO)
- hi — (Hardware IRQ) процент времени, которое процессор тратит на обработку прерываний на уровне оборудования (hardware- прерываний).
- si — (Software Interrupts) процент времени, затраченное на работу обработку software- прерываний (network)
- st — (Steal Time) время, «украденное» гипервизором у этой виртуальной машины для других задач (например работа другой виртуальной машины)
Interactive Commands
The following commands are supported while in htop:
- Arrows, PgUP, PgDn, Home, End
- Scroll the process list.
- Space
- Tag or untag a process. Commands that can operate on multiple processes, like «kill», will then apply over the list of tagged processes, instead of the
currently highlighted one. - U
Untag all processes (remove all tags added with the Space key).
s
Trace process system calls: if strace(1) is installed, pressing this key will attach it to the currently selected process, presenting a live update of
system calls issued by the process.
l
Display open files for a process: if lsof(1) is installed, pressing this key will display the list of file descriptors opened by the process.
F1, h, ?
Go to the help screen
F2, S
Go to the setup screen, where you can configure the meters displayed at the top of the screen, set various display options, choose among color schemes, and
select which columns are displayed, in which order.
F3, /
Incrementally search the command lines of all the displayed processes. The currently selected (highlighted) command will update as you type. While in search
mode, pressing F3 will cycle through matching occurrences.
F4, \
Incremental process filtering: type in part of a process command line and only processes whose names match will be shown. To cancel filtering, enter the
Filter option again and press Esc.
F5, t
Tree view: organize processes by parenthood, and layout the relations between them as a tree. Toggling the key will switch between tree and your previously
selected sort view. Selecting a sort view will exit tree view.
F6, <, >
Select a field for sorting. The current sort field is indicated by a highlight in the header.
F7, ]
Increase the selected process’s priority (subtract from ‘nice’ value). This can only be done by the superuser.
F8, [
Decrease the selected process’s priority (add to ‘nice’ value)
F9, k
«Kill» process: sends a signal which is selected in a menu, to one or a group of processes. If processes were tagged, sends the signal to all tagged
processes. If none is tagged, sends to the currently selected process.
F10, q
Quit
I
Invert the sort order: if sort order is increasing, switch to decreasing, and vice-versa.
+, —
When in tree view mode, expand or collapse subtree. When a subtree is collapsed a «+» sign shows to the left of the process name.
a (on multiprocessor machines)
Set CPU affinity: mark which CPUs a process is allowed to use.
u
Show only processes owned by a specified user.
M
Sort by memory usage (top compatibility key).
P
Sort by processor usage (top compatibility key).
T
Sort by time (top compatibility key).
F
«Follow» process: if the sort order causes the currently selected process to move in the list, make the selection bar follow it. This is useful for
monitoring a process: this way, you can keep a process always visible on screen. When a movement key is used, «follow» loses effect.
K
Hide kernel threads: prevent the threads belonging the kernel to be displayed in the process list. (This is a toggle key.)
H
Hide user threads: on systems that represent them differently than ordinary processes (such as recent NPTL-based systems), this can hide threads from
userspace processes in the process list. (This is a toggle key.)
Ctrl-L
Refresh: redraw screen and recalculate values.
Numbers
PID search: type in process ID and the selection highlight will be moved to it.
Using htop
To launch htop, simply type the command in your terminal. The header shows the CPU averages and the main body of the application contains more information about each process.

Here is what each column means:
PID: A process’s process ID number.USER: The owner of the process.PR: The process’s priority. The lower the number, the higher the priority.NI: The nice value of the process, this affects its priority.VIRT: The virtual memory the process is using.RES: The physical RAM the process is using, usually measured in kilobytes.SHR: The shared memory the process is using.S: The current status of the process (sleeping, zombied, running, traced or uninterruptedly sleeping).%CPU: The percentage of the processor time used by the process. It displays the % of CPU used at the end of the bar. The bar itself will shows low-priority in blue, normal in green, kernel in red.%MEM: The percentage of physical RAM used by the process.TIME+: The processor time the process has used.COMMAND: The name of the command that initiated the process.
The footer displays the htop menu commands.
Information on processes:
Htop will lists all the running processes on a system with information about how much cpu and memory each process is using as well as the command used to start the process.

Here is a list that explains what each column means.
- PID: A process’s process ID number.
- USER: The process’s owner.
- PR: The process’s priority. The lower the number, the higher the priority.
- NI: The nice value of the process, which affects its priority.
- VIRT: How much virtual memory the process is using.
- RES: How much physical RAM the process is using, measured in kilobytes.
- SHR: How much shared memory the process is using.
- S: The current status of the process (zombied, sleeping, running, uninterruptedly sleeping, or traced).
- %CPU: The percentage of the processor time used by the process.
- %MEM: The percentage of physical RAM used by the process.
- TIME+: How much processor time the process has used.
- COMMAND: The name of the command that started the process.
Installing htop
First update the package repository cache of your Ubuntu operating system with the following command:
$ sudo apt-get update

The package repository cache should be updated.

htop is available on the official package repository of Ubuntu 17.10 Artful Aardvark. To install htop, run the following command:
$ sudo apt-get install htop

htop should be installed.

Now run the following command to start htop:
$ htop

This is the main window of htop.

Basics of htop
Now I am going to talk about the interface of htop program.
On the marked section in the screenshot below, you can see the uptime of your computer. As you can see, my computer is running for 2 hours 41 minutes and 58 seconds.

You can find how much of the CPU is used in the marked section in the screenshot below. As you can see I have 2 cores in my processor and only 0.7% out of 100% of each is used.

In the marked section in the screenshot below, you can find how much main memory or RAM is available and how much is used. You can also find out how much Swap space is available and how much of it is used.
As you can see, I have 2.91 GB or RAM available and 1.67 GB is used. I also have 947 MB of swap space available and 0 KB is used. Note that, the more swap is used, the more you should be worried. If more swap is used, you should upgrade your main memory or RAM.

Search for Process
You can search for a specific process with htop. For example, let’s say you want to search for the process ‘firefox’.
First start htop and press <F3>. A search box should appear as shown in the screenshot below.

Now type in ‘firefox’, and you should see firefox process selected as shown in the screenshot below. You can see that the process id (PID) is 2240 and the process is owned by USER shovon.

To go to the next firefox process or search result, press <F3> again.

Once you find the process you’re looking for, press <Enter> to select it.
Kill a Process
You can also kill a process with htop utility.
First select a process using the <Up> and <Down> arrow keys or by searching for a process using <F3>.
Let’s say PID 2240 is the process I want to kill. I selected the process as you can see in the screenshot below.

Now to kill the process, press <F9>. You should see the following window as shown in the screenshot below. In the marked section, there are different Linux signals listed. These signals are used to manage Linux processes. To kill a process, the default signal for htop is SIGTERM. You can of course choose any other signals using the <Up> and <Down> arrow keys.
Once you select the signal you want to send to the process, press <Enter>. I suggest you send the default signal SIGTERM if you don’t know what to do here.

The process should be killed as shown in the screenshot below.

Switching to Tree View
The default view mode of htop is Sorted.

You can switch to Tree view if you want by pressing <F5> as shown in the screenshot below.

You can go back to Sorted view again by pressing <F5>.
Customizing htop Window
You can press <F2> to go to htop configuration window as you can see from the screenshot below.
From here you can customize the main window of htop. For example, you can hide or show things, change colors and many more. It is out of the scope of this article. But it should be easy enough to figure out on your own.

Once you’re done, you can exit out of htop window using the ‘q’ key.
That’s how you install and use htop on Ubuntu 17.10 Artful Aardvark. Thanks for reading this article.
Compiling from source
To compile htop from source, we need to have ncurses4 or newer and development tools/build essential installed. Here are the steps to installing htop from source.
$ wget -qO- wget http://hisham.hm/htop/releases/2.0.2/htop-2.0.2.tar.gz | tar xvz -C . $ tar zxf htop-2.0.2.tar.gz $ cd htop-2.0.2/ $ ./configure $ make $ make install
If you encountered an error during compiling, then it means you don’t have one or more of the dependencies installed. Here’s how to install your dependencies.
For Ubuntu and debian distros, run the command:
$ sudo apt-get install build-essential libssl-dev libncurses5
For Fedora 26 and newer, use the command:
$ sudo dnf install @development-tools ncurses
For CentOS 7, RedHat 7 and other rpm-based distros, run the command:
$ sudo yum groupinstall "Development Tools" $ sudo yum install ncurses-devel
Use htop like a pro:
Htop has some very useful feature built-in to make one’s life easier when working with system processes, here a list of feature that I find very helpful.
- Scroll the process list horizontally and vertically using the arrow keys
- Kill a process by pressing the F9′ key
- Renice a process by pressing the ‘F7’ or ‘F8’ key’s
- List open files used by a process by pressing the ‘l’ key
- Display only processes of a single user by pressing the ‘u’ key
- Display processes sorted by any htop column by pressing the ‘F6’ key
- Display processes in a tree view by pressing the ‘F5’ key
Another useful option in htop is the setup menu which can be accessed by pressing the ‘F2’ key. Here you can change the behavior of the meter bar, customize some of the htop display options, choose a color theme for the htop output and choose what columns needs to be displayed for the processes in htop.
The difference between VIRT, RES and SHR:
- VIRT stands for the virtual size of a process, which is the sum of memory it is actually using, memory it has mapped into itself (for instance the video card’s RAM for the X server), files on disk that have been mapped into it (most notably shared libraries), and memory shared with other processes. VIRT represents how much memory the program is able to access at the present moment.
- RES stands for the resident size, which is an accurate representation of how much actual physical memory a process is consuming. (This also corresponds directly to the %MEM column)
- SHR indicates how much of the VIRT size is actually sharable memory or libraries. In the case of libraries, it does not necessarily mean that the entire library is resident. For example, if a program only uses a few functions in a library, the whole library is mapped and will be counted in VIRT and SHR, but only the parts of the library file containing the functions being used will actually be loaded in and be counted under RES.
интерфейс htop
После установки htop вас встретит интерфейс, показанный на следующем рисунке. На первый взгляд, это может показаться ошеломляющим, но давайте разберемся с каждой частью его интерфейса. В левом верхнем углу вы найдете информацию о процессоре, памяти и подкачке с анимированными полосами, показывающими потребление аппаратных ресурсов. В верхнем правом углу вы найдете информацию о задачах, выполняемых на сервере, средней загрузке ЦП для каждого ядра и времени работы системы.

htop показывает аппаратные ресурсы
В средней части htop показывает список запущенных процессов в системе. Для каждого процесса вы можете увидеть много информации. Но самым важным является пользователь, владеющий процессом, и процессор. Кроме того, вы увидите процент использования памяти процессом и время его работы.

htop показывает запущенные процессы и информацию о них
В нижней части htop перечислены различные параметры, как показано на рисунке ниже.

варианты для htop и ресурсов
Настройки довольно понятны, но нажатие клавиши F1 вызывает страницу справки htop.

Страница справки htop, показывающая, как использовать ее функции
SSH это здорово, я хочу узнать больше!
Поздравляем! Вам удалось установить htop, который является одним из первых инструментов, которые вы узнаете из нашего введения в серию SSH. После прочтения нашей вводной статьи вы должны знать, что такое SSH и htop и как они могут позволить вам подключаться к серверу Linux для мониторинга. Но SSH может сделать гораздо больше!
В наших будущих публикациях вы узнаете, как можно подключиться к серверу без использования пароля с помощью ключей и как настроить прокси-сервер SOCKS для обхода брандмауэра, блокирующего различные ресурсы. Скоро зайдите и узнайте, как освоить SSH.
Источник записи: https://www.smarthomebeginner.com
Расшифровка столбцов
- PID
- USER
- PR
- NI
- VIRT — (kb — килобайты). Общее количество виртуальной памяти, используемой программой. VIRT = SWAP + RES.
- RES — (kb). Количество резидентной (не перемещаемой в swap) памяти. RES = CODE + DATA.
- SHR — (kb). Количество разделяемой (shared) памяти программы.
- S — статус процесса.
- %CPU
- %MEM
- TIME+
- COMMAND
htop

Homepage: htop
Htop – основанный на ncurses просмотрщик процессов подобный top, htop, atop интерактивные просмоторщики процессов, но позволяющий прокручивать список процессов вертикально и горизонтально, чтобы видеть их полные параметры запуска. Управление процессами (остановка, изменение приоритета) может выполняться без ручного ввода их идентификаторов.
Htop экономит одну колонку и показывает в колонке PID(процесс) то, что Использование ps для мониторинга процессов (ps -eLf) показывает в колонке LWP(поток; процесс — контейнер для потоков)
htop в CentOS установка из репозитория см. rpm# wget http://download.fedora.redhat.com/pub/epel/5/x86_64/htop-0.8.3-1.el5.x86_64.rpm
# rpm -i htop-0.8.3-1.el5.x86_64.rpm
Замечания к BSD системам, при использовании htop
При установки htop на FreeBSD требует смонтированную систему linprocfs, для совместимости с Linux. linprocfs — the Linux process file system, or linprocfs, emulates a subset of Linux’ process file system and is required for the complete operation of some Linux binaries.
> man linprocfs ... > mount -t linprocfs linproc /compat/linux/proc > df -h ... linprocfs 4.0K 4.0K 0B 100% /usr/compat/linux/proc > cd /usr/ports/sysutils/htop > make install clean
Скрипт для монтирования linprocfs при загрузки FreeBSD:
> ee usrlocaletcrc.d0start.sh #! /bin/sh #for htop sbinmount -t linprocfs linproc compatlinuxproc
Или прописать в fstab строку и для проверки примонтировать командой mount linproc
linproc /usr/compat/linux/proc linprocfs rw 0 0
htop command keyboard shortcut keys
Now that you install htop on Ubuntu. It is time to learn keyboard shortcuts. The following commands are supported while in htop session:
| Command | Description |
|---|---|
| Up arrow key | Select (highlight) the previous process in the process list. Scroll the list if necessary. |
| Down arrow key | Select (highlight) the next process in the process list. Scroll the list if necessary. |
| Left arrow key | Scroll the process list left. |
| Right arrow key | Scroll the process list right. |
| PgUp, PgDn | Scroll the process list up or down one window. |
| Home | Scroll to the top of the process list and select the first process. |
| End | Scroll to the bottom of the process list and select the last process. |
| s | Trace process system calls: if strace(1) is installed, pressing this key will attach it to the currently selected process, presenting a live update of system calls issued by the process. |
| l | Display open files for a process: if lsof(1) is installed, pressing this key will display the list of file descriptors opened by the process. |
| u | Show only processes owned by a specified user. |
| M | Sort by memory usage (top compatibility key). |
| P | Sort by processor usage (top compatibility key). |
| T | Sort by time (top compatibility key). |
| F | “Follow” process: if the sort order causes the currently selected process to move in the list, make the selection bar follow it. This is useful for monitoring a process: this way, you can keep a process always visible on screen. When a movement key is used, “follow” loses effect. |
| K | Hide kernel threads: prevent the threads belonging the kernel to be displayed in the process list. (This is a toggle key.) |
| H | Hide user threads: on systems that represent them differently than ordinary processes (such as recent NPTL-based systems), this can hide threads from userspace processes in the process list. (This is a toggle key.) |
| p | Show full paths to running programs, where applicable. (This is a toggle key.) |
| Ctrl-L | Rfresh the screen. |
| F1 | See this help menu. |
| h | Same as above. |
| ? | Again, same as above. |
| F10 | Quit htop |
| q | Exit htop (same as above) |