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:
- Simple Usage: Basic default commands.
- Detailed View: Shows diagnostic information.
- Advanced Actions: Can chain parameters for scripting.
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]
topuses a lot of keyboard shortcuts. Pressqto quit,Mto sort by memory, andPto sort by CPU.
🔗 Related Commands
Here are some related posts on cli_tty1 you might want to check out:
- sort : Sort lines of text files.