top Command in Linux (original) (raw)

Last Updated : 14 May, 2026

The top command is a real-time system monitoring utility available on Linux systems. It presents a continuously updated view of running processes along with overall system resource usage such as CPU load, memory consumption, and system uptime.

Example: Run top Without Any Options

**Command:

top

top

live view of system activity

Running top without options starts the interactive monitoring interface. The display refreshes automatically and lists active processes along with CPU usage, memory usage, load averages, and system uptime. Press q to exit the interface.

Here,

Syntax:

top [options]

Interpreting top Command Output

The top command output is divided into several sections, each with specific information about system performance and processes. This section provides a breakdown of the output based on the information it shows.

1. Uptime / Summary

When you first open the top command, the initial line, often referred to as the header or summary line, displays information similar to what you see when you use the uptime command. It shows:

process1

2. Tasks

The Tasks section provides an overview of all processes currently managed by the system. It categorizes them based on their state.

process2

3. %Cpu(s)

The %CPU line shows how the CPU time is distributed across different types of tasks. This helps in identifying which activities are consuming CPU resources.

process3

4. Memory (MiB Mem)

The MiB Mem line provides detailed information about the system's physical memory (RAM) usage. It helps in understanding how memory is allocated and used by processes and the system.

process4

5. Swap (MiB Swap)

The MiB Swap line shows information about swap space usage, which acts as overflow memory when RAM is full. Monitoring swap helps identify memory pressure on the system.

process5

Common Options Used in top Command

-v (Display Version Information)

The -v option prints the installed version of the top utility and exits immediately.

**Syntax:

top -v or top --version

**Example:

top -v

**Output:

versionnn

Output

-p (Monitor a Specific Process by PID)

The -p option limits the display to only the process or processes you choose by their Process ID (PID). Other running processes will not appear.

**Syntax:

top -p

**Example:

top -p 7760

**Output:

specific

Output

-M (Set Memory Display Unit)

The -M option changes the unit used to display memory in top. By default, memory may be shown in kilobytes, but this option allows switching between kilobytes, megabytes, or gigabytes.

**Syntax:

top -M [k or m or g]

**Example:

top -M k

Displays memory usage in kilobytes

**Note: The -M option is available in some versions of top, particularly in older or alternative implementations (like on BSD or in older procps versions)

-b (Batch Mode for Logging or Scripts)

The -b option runs top in batch mode, which outputs the data in a plain text format instead of the interactive interface. This is useful for saving or processing the output in scripts.

**Syntax:

top -b [options]

**Example:

top -b -n 1

**Output:

batches

Output

-1 (Show CPU Usage Per Core)

The -1 option displays CPU usage for each individual core instead of showing an overall average.

**Syntax:

top -1

**Example:

top -1

**Output:

memoryusage

Output

-h (Display Help Information)

The -h option prints help information about top options and usage, then exits.

**Syntax:

top -h

**Example:

top -h

**Output:

help

Output

Interactive Keys in top

The top command supports several interactive keys to manage processes, adjust display, and sort information while it is running. These keys allow real-time control without restarting the command.

k (Kill a Process)

The k key in the interactive top interface allows terminating a running process by specifying its PID.

**Steps:

**Example:

top PID to Kill = 1869

**Output:

kill

Output

r (Change Process Priority / Renice)

The r key in the interactive top interface allows adjusting the priority (nice value) of a running process, which affects CPU scheduling.

**Steps:

**Example:

top PID to renice : 9 nice values range from -20 to 19

**Output:

renice

Output

z (Toggle Color/Highlighting)

Enables color coding of processes to improve readability and quickly identify resource-intensive processes.

**Steps:

top-z

Output

q (Quit Top Interface)

Exits the top interactive interface immediately and returns to the terminal prompt.

**Steps:

exit

Alternate Example:

sudo apt install htop htop

**Output:

htop

Output

Other Useful Command Options using in top command

**1) Exit Top Command After Specific repetition:

Top output keeps refreshing until you press ‘q‘. With below command top command will automatically exit after 10 number of repetition.

top -n 10

**2) Display Specific User Process

top -u paras

**3) Highlight Running Process in Top: Press ‘z‘ option in running top command will display running process in color which may help you to identified running process easily.

**4) Shows Absolute Path of Processes: Press ‘c‘ option in running top command, it will display absolute path of running process.

**5) Sort by CPU Utilisation: Press (Shift+P) to sort processes as per CPU utilization.

**6) Secure Mode: Use top in Secure mode.

top -s

**7) Command Line: The below command starts top with last closed state.

top -c

**8) Delay time: It tells delay time between screen updates.

top -d seconds.tenths

**9) Color and Highlighting: using the z key toggles color and highlighting of the process list. This feature enhances visibility by color-coding different aspects of the processes, such as CPU usage, memory consumption, and process states (running, sleeping, etc.). It helps users quickly identify resource-intensive processes or anomalies in system behavior.

**10) Alert Display Mode: Pressing the A key toggles the alternative display mode. This mode rearranges the display to show multiple windows, each focusing on different aspects of system performance, such as CPU usage, memory, and processes.

Comprehensive System Monitoring with Glances on Linux

Glances in Linux is a system monitoring tool that provides:

  1. **Overview Dashboard: Displays real-time statistics on CPU, memory, disk, network, and processes.
  2. **Process Table: Lists detailed information about running processes, including CPU and memory usage.
  3. **Alerts and Notifications: Alerts users about critical system metrics exceeding predefined thresholds.
  4. **Plugins and Extensions: Supports various plugins for additional monitoring capabilities, such as Docker and SNMP.
  5. **Interactive UI: Offers an interactive command-line interface or a web-based interface for monitoring multiple systems remotely.

Alternatives to top for System Monitoring

While top is useful, several other tools provide enhanced features, interactivity, or historical data tracking.