htop

process managementLinux/Unix
The htop command is one of the most frequently used commands in Linux/Unix-like operating systems. htop The htop command is an enhanced interactive process viewer for Linux systems. It provides a full-color terminal interface that displays system summary information and a list of processes in a more user-friendly way than the traditional top command. htop offers advanced features like vertical and horizontal scrolling, tree view, and mouse operation.

Quick Reference

Command Name:

htop

Category:

process management

Platform:

Linux/Unix

Basic Usage:

htop [options] [arguments]

Common Use Cases

  • 1

    Process monitoring

    Display dynamic information about running processes

  • 2

    Resource usage

    Monitor CPU, memory, and I/O usage of processes

  • 3

    Troubleshooting

    Diagnose issues with running processes

  • 4

    Scripting

    Use in shell scripts to monitor and manage processes

Syntax

htop [options]

Options

Option Description
-C, --no-color Start htop in monochrome mode
-d, --delay=DELAY Set the delay between updates, in tenths of seconds
-h, --help Display help message and exit
-p, --pid=PID[,PID...] Show only the specified processes
-s, --sort-key=COLUMN Sort by specified column (use --sort-key=help for a column list)
-t, --tree Show processes in tree view
-u, --user=USERNAME Show only processes of a specific user
-v, --version Display version information and exit
--readonly Run htop in a read-only mode, disabling interactive commands that change processes

Examples

How to Use These Examples

The examples below show common ways to use the htop command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.

#

Basic Usage:

htop

Launch htop with the default display settings.

htop -u username

Display only processes owned by a specific user.

htop -p 1234,5678

Show only specific processes by their PIDs.

Display Options:

htop -t

Display processes in tree view mode, showing parent-child relationships.

htop -s PERCENT_CPU

Sort processes by CPU usage at startup.

htop -s PERCENT_MEM

Sort processes by memory usage at startup.

Interactive Commands:

htop
Then press:
F1 (for help) F9 (to kill a process) F7/F8 (to decrease/increase process priority) F5 (to toggle tree view) F6 (to select sort column)

Interactive commands that can be used while htop is running.

Advanced Features:

htop
Then press:
u (to filter by user)
F2 (to access setup menu for customization) / (to search for processes) \ (to filter processes by name) Space (to tag/select multiple processes)

Advanced interactive features for filtering and manipulating processes.

Custom Configuration:

htop --no-color

Run htop without color (useful for some terminals or color blindness).

htop -d 10

Set the delay between updates to 10 tenths of a second (1 second).

htop
Then press:
F2 (to access setup menu) Customize display, then F10 (to save and exit setup) F10 (to quit htop)

Configuration is automatically saved to ~/.config/htop/htoprc when you exit.

Try It Yourself

Practice makes perfect! The best way to learn is by trying these examples on your own system with real files.

Understanding Syntax

Pay attention to the syntax coloring: commands, options, and file paths are highlighted differently.

Notes

Interactive Function Keys:

  • F1: Help - Shows the help screen
  • F2: Setup - Configures display options, columns and colors
  • F3: Search - Search for process names or commands
  • F4: Filter - Filter processes by specific text
  • F5: Tree - Toggle process tree view (parent-child relationship)
  • F6: SortBy - Select the sort column
  • F7: Nice - (Decrease) Decrease process priority (make nicer)
  • F8: Nice + (Increase) Increase process priority
  • F9: Kill - Send a signal to selected process
  • F10: Quit - Exit htop

Keyboard Shortcuts:

  • Up/Down: Select previous/next process
  • Left/Right: Scroll horizontally when there are more columns
  • PgUp/PgDn: Scroll the process list by one page
  • Home/End: Jump to the first/last process
  • Space: Tag/select a process (for multiple operations)
  • U: Untag all processes (clear selection)
  • u: Show processes of a specific user
  • M: Sort by memory usage
  • P: Sort by CPU usage
  • T: Sort by time
  • k: Show/hide kernel threads
  • H: Show/hide user threads
  • +/-: Expand/collapse process subtree
  • I: Invert sort order
  • t: Toggle tree view
  • /: Search
  • \: Filter by process name
  • Ctrl-L: Refresh display

Display Meters and Columns:

  • htop displays various meters at the top of the screen showing CPU, memory, and swap usage
  • Use F2 to access the setup menu where you can add, remove, and rearrange meters
  • Available meters include: Clock, Load Average, CPU, Memory, Swap, Battery, and Network usage
  • Process columns can be configured to show exactly the information you need
  • Column options include: PID, USER, PRIORITY, NICE, M_SIZE (memory size), M_RESIDENT, M_SHARE, STATE, PERCENT_CPU, PERCENT_MEM, TIME, COMM (command), and many more

Process Management:

  • Press F9 to send signals to processes (SIGTERM, SIGKILL, etc.)
  • Press F7/F8 to adjust process priority (nice value)
  • Use Space to select multiple processes, then F9 to kill all selected processes at once
  • Press s to trace process system calls (requires strace to be installed)
  • Press l to open the file that the process has open (requires lsof to be installed)

Color Schemes and Customization:

  • Access color schemes through F2 (Setup) → Colors
  • Default color schemes include Black on White, White on Black, and more
  • Process highlighting based on status: green for running, red for high CPU/memory usage
  • Customize column display through F2 → Columns
  • Configuration is saved to ~/.config/htop/htoprc

Advanced Features:

  • Tree View: Shows parent-child process relationships (toggle with F5)
  • Process Filtering: Use F4 or \ to filter processes by name
  • Search: Press F3 or / to search for processes
  • User Filtering: Press u to show only processes of specific users
  • Follow Process: Press F to "follow" a process (keep it on screen)
  • Mouse Support: Click on meters, column headers, and processes for quick interaction

Common Uses:

  • Monitoring system resource usage in real-time
  • Identifying resource-intensive processes
  • Managing processes (killing, renicing) through an intuitive interface
  • Investigating parent-child process relationships
  • Monitoring specific processes or users
  • System performance troubleshooting

Advantages over top:

  • More intuitive and visually appealing interface
  • Mouse support for easier navigation
  • Vertical and horizontal scrolling to see all information
  • Process tree view to understand process relationships
  • Better process filtering and search capabilities
  • More customization options for display and functionality
  • Easier process management with keyboard shortcuts and mouse

Related Commands:

  • top - Traditional process viewer that htop enhances
  • ps - Provides a snapshot of current processes
  • pstree - Displays processes in a tree format
  • kill - Send signals to processes
  • nice - Run a program with modified scheduling priority
  • renice - Alter priority of running processes
  • free - Display memory usage
  • vmstat - Report virtual memory statistics

Tips & Tricks

1

Use the -d option to delay between updates

2

Use the -c option to show full command line

3

Use the -s option to sort by specific column

4

Use the -u option to display information about users

5

Use the -p option to specify a process ID to monitor

Common Use Cases

Process monitoring

Display dynamic information about running processes

Resource usage

Monitor CPU, memory, and I/O usage of processes

Troubleshooting

Diagnose issues with running processes

Scripting

Use in shell scripts to monitor and manage processes

System administration

Manage and optimize system resources

Related Commands

These commands are frequently used alongside htop or serve similar purposes:

Use Cases

1

Process monitoring

Display dynamic information about running processes

2

Resource usage

Monitor CPU, memory, and I/O usage of processes

3

Troubleshooting

Diagnose issues with running processes

4

Scripting

Use in shell scripts to monitor and manage processes

5

System administration

Manage and optimize system resources

Learn By Doing

The best way to learn Linux commands is by practicing. Try out these examples in your terminal to build muscle memory and understand how the htop command works in different scenarios.

$ htop
View All Commands