Operations 5 min read

Master Linux’s top Command: Real‑Time Process Monitoring Made Easy

This guide introduces the Linux top command, explains its syntax and common options, details interactive key commands, and provides practical examples for monitoring processes, CPU, memory, threads, and specific users, helping users efficiently diagnose system performance issues.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Master Linux’s top Command: Real‑Time Process Monitoring Made Easy

The top command is a powerful command‑line tool for real‑time monitoring of system processes and resource usage on Linux, displaying a continuously updated list of running processes with CPU, memory, I/O, and other metrics.

Syntax

Run top --help to see usage information; the basic form is:

top -hv | -bcHiOSs -d secs -n max -u|U user -p pid(s) -o field -w [cols]

For detailed documentation, use man top.

Common Options

-d seconds

: Set the refresh interval (default 3 seconds). -n iterations: Limit the number of updates; default is infinite. -p pid: Show information for specific process IDs (comma‑separated). -u user: Show only processes owned by the given user. -H: Display processes in a hierarchical (parent/child) view. -i: Hide idle processes. -b: Run in batch mode, suitable for redirecting output to a file.

Interactive Commands

Press k : Kill the selected process.

Press t : Toggle display of CPU, memory, and other fields.

Press m : Sort by memory usage.

Press P : Sort by CPU usage.

Press h : Show the help screen.

Press q : Quit top.

Examples

1. Display the default top view:

top

2. Update every 5 seconds and exit after 10 iterations:

top -d 5 -n 10

3. Show information for a specific PID (e.g., 11):

top -p 11

4. Show all threads of a specific PID:

top -H -p 11

5. Display CPU usage for all cores (press 1 after starting top):

6. Show the command‑line arguments of each process:

top -H -c -p 12210

7. Show processes owned by a specific user (e.g., root):

top -u root

In summary, the top command provides a real‑time view of system processes and resource consumption, enabling users to quickly identify bottlenecks and performance issues, making it an essential tool for Linux system administration.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

CLIprocess managementlinuxUnixsystem-monitoringtop command
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.