Linux Terminal Command: top

The top command is an essential tool in Process & Job Control. In this tutorial, we will explore what top does, look at everyday examples, and cover advanced options to supercharge your command-line workflow.


Concept & Explanation

The top command displays system load, CPU, memory metrics, and an active process list sorted by CPU usage, updating every few seconds.


Common Options & Syntax

top [options] [arguments]

Here are the most common flags used with top:


1. Interactive Example (Simple)

Here is how most people run the command:

# Example
top

What it does: Launches the interactive real-time system monitor.


2. Power-User Example (Advanced)

For scripting and advanced diagnostics, use this configuration:

# Advanced
top -b -n 1 > process_dump.txt

What it does: Runs top in batch mode (-b), outputs exactly one iteration (-n 1), and writes it to a file for system diagnostics.


⚙️ Warning & Common Pitfalls

[!WARNING] top uses a lot of keyboard shortcuts. Press q to quit, M to sort by memory, and P to sort by CPU.


Here are some related posts on cli_tty1 you might want to check out: