Htop
lastmod 2026-01-06created 2018-12-1126 edits
htop is an interactive text-mode process viewer for Unix systems. It aims to be a better top.
This is htop, an interactive process viewer. It requires ncurses. It is developed primarily on Linux, but we also have code for running under FreeBSD and Mac OS X (help and testing are wanted for these platforms!)
This software has evolved considerably over the years, and is reasonably complete, but there is always room for improvement.
Preview
Screenshot-htop.png
Comparison between htop and classic top
- In htop you can scroll the list vertically and horizontally to see all processes and full command lines.
- In top you are subject to a delay for each unassigned key you press (especially annoying when multi-key escape sequences are triggered by accident).
- htop starts faster (top seems to collect data for a while before displaying anything).
- In htop you don't need to type the process number to kill a process, in top you do.
- In htop you don't need to type the process number or the priority value to renice a process, in top you do.
- In htop you can kill multiple processes at once.
- top is older, hence, more tested.
Process information
- PID: Process ID number of the process
- USER: Owner of the process
- PR: Priority of the process
- NI: The process's nice value, which affects its priority
- VIRT: Amount of virtual memory used by the process
- RES: Amount of physical RAM used by the process (in kilobytes) - (Resident set size; RSS) - Use this one to calculate memory usage.
- SHR: Amount of shared memory used by the process
- S: Current state of the process (zombied, sleeping, running, uninterruptedly sleeping, traced)
- %CPU: Percentage of time the process has used the processor
- %MEM: Percentage of physical RAM used by the process
- TIME+: Time the process has used the processor
- COMMAND: Name of the command used to start the process
Functions
- F1(help): Shows help and what each shortcut key does.
- F2(Setup): The htop settings menu.
- F3(Search): Search for processes. ( You can also search with the '/' key.)
- F4(Filter): Monitor only the processes you want. ( = ps -ef | grep mysqld )
- F5(Tree): Shows the parent-child relationships of processes as a tree. Use the + or - key to expand or collapse the tree. ( = same as the pstree command )
- F6(Sort): View processes sorted however you want, by CPU, memory, user, etc. ( The field being sorted is highlighted in color, so it is easy to see. )
- F7, F8(Nice): Shortcut keys for changing process priority. ( The f7 key raises the priority and the f8 key lowers it. -> That is, the smaller the value, the higher the priority. )
- F9(Kill): Shortcut key that terminates a process. ( = kill -9 {PID} ) -> To terminate several processes at once, select multiple processes with the "space" key, then press F9 to terminate them.
- F10(quit): Quit htop
Other functions
- u: Shows only the processes of a specific user.
- i: Changes the I/O priority.
- s: Select a process and press the "s" key to show the strace of that process. ( = system call trace (strace) )
- l: Select a process and press the "l" key to see the files that process has open.
- Typing a number on the htop screen finds the process with that PID.
Columns
List of columns you can see by pressing F2
- PID - Process/thread ID
- STATE - Process state (S sleeping, R running, D disk, Z zombie, T traced, W paging, I idle)
- PPID - Parent process ID
- PGRP - Process group ID
- SESSION - Process's session ID
- TTY_NR - Controlling terminal
- TPGID - Process ID of the fg process group of the controlling terminal
- MINFLT - Number of minor faults which have not required loading a memory page from disk
- CMINFLT - Children processes' minor faults
- MAJFLT - Number of major faults which have required loading a memory page from disk
- CMAJFLT - Children processes' major faults
- UTIME - User CPU time - time the process spent executing in user mode
- STIME - System CPU time - time the kernel spent running system calls for this process
- CUTIME - Children processes' user CPU time
- CSTIME - Children processes' system CPU time
- PRIORITY - Kernel's internal priority for the process
- NICE - Nice value (the higher the value, the more it lets other processes take priority)
- STARTTIME - Time the process was started
- PROCESSOR - Id of the CPU the process last executed on
- M_VIRT - Total program size in virtual memory
- M_RESIDENT - Resident set size, size of the text and data sections, plus stack usage
- M_SHARE - Size of the process's shared pages
- M_TRS - Size of the text segment of the process
- M_DRS - Size of the data segment plus stack usage of the process
- M_LRS - The library size of the process (calculated from memory maps)
- M_DT - Size of the dirty pages of the process (unused since Linux 2.6; always 0)
- ST_UID - User ID of the process owner
- PERCENT_CPU - Percentage of the CPU time the process used in the last sampling
- PERCENT_MEM - Percentage of the memory the process is using, based on resident memory size
- USER - Username of the process owner (or user ID if name cannot be determined)
- TIME - Total time the process has spent in user and system time
- NLWP - Number of threads in the process
- TGID - Thread group ID (i.e. process ID)
- PERCENT_NORM_CPU - Normalized percentage of the CPU time the process used in the last sampling (normalized by cpu co
- CTID - OpenVZ container ID (a.k.a. virtual environment ID)
- VPID - OpenVZ process ID
- VXID - VServer process ID
- RCHAR - Number of bytes the process has read
- WCHAR - Number of bytes the process has written
- SYSCR - Number of read(2) syscalls for the process
- SYSCW - Number of write(2) syscalls for the process
- RBYTES - Bytes of read(2) I/O for the process
- WBYTES - Bytes of write(2) I/O for the process
- CNCLWB - Bytes of cancelled write(2) I/O
- IO_READ_RATE - The I/O rate of read(2) in bytes per second for the process
- IO_WRITE_RATE - The I/O rate of write(2) in bytes per second for the process
- IO_RATE - Total I/O rate in bytes per second
- CGROUP - Which cgroup the process is in
- OOM - OOM (Out-of-Memory) killer score
- IO_PRIORITY - I/O priority
- PERCENT_CPU_DELAY - CPU delay %
- PERCENT_IO_DELAY - Block I/O delay %
- PERCENT_SWAP_DELAY - Swapin delay %
- M_PSS - proportional set size, same as M_RESIDENT but each page is divided by the number of processes sharing it.
- M_SWAP - Size of the process's swapped pages
- M_PSSWP - shows proportional swap share of this mapping, Unlike "Swap", this does not take into account swapped out
- CTXT - Context switches (incremental sum of voluntary_ctxt_switches and nonvoluntary_ctxt_switches)
- SECATTR - Security attribute of the process (e.g. SELinux or AppArmor)
- COMM - comm string of the process from /proc/[pid]/comm
- EXE - Basename of exe of the process from /proc/[pid]/exe
- CWD - The current working directory of the process
Calculating memory usage with /proc/meminfo
In htop ...
- Total used memory = MemTotal-MemFree
- Non cache / buffer memory (green) = Total used memory-(Buffers + Cached memory)
- Buffers (blue) = Buffers
- Cached memory (yellow) = Cached+ SReclaimable-Shmem
- Swap = SwapTotal-SwapFree
See also
- ps
- top
- htop
- iotop - Top for Disk I/O
- ctop
- Glances
- nmon
- free
- Resource usage
- procs - replacement for ps written in Rust.
- LXTask - (LXDE; lightweight task manager]])
- mpstat
- iotop - Disk I/O
- Sampler - Tool for running shell commands, visualization, and alerting
- iftop - shows network traffic by service and host
- NetHogs
- lm-sensors - Turns out it gets installed along as a dependency
Favorite site
- Github - htop
- [Recommended] htop explained | peteris.rocks 1
- Internet Nayana :: How to use Htop (Linux Process Monitoring)
- Linux Portal - htop: a more user-oriented monitoring tool than top
- (ubuntu) Installing and using htop on Linux
References
-
Htop_explained_-_peteris.rocks.pdf ↩