Operations 9 min read

Master Linux ps Command: Powerful Tips for Process Monitoring & Reporting

Learn how to master the Linux ps command—from basic options and output formats to advanced filtering by user, CPU, memory, threads, and tree view, plus real-time monitoring with watch—so you can generate custom process reports for effective system administration.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Master Linux ps Command: Powerful Tips for Process Monitoring & Reporting

1. What is ps?

To monitor and control processes you first need to know their current state; the ps command displays a snapshot of running processes, showing which are active, terminated, zombie, or consuming excessive resources.

ps shows a snapshot of process status, not a continuous stream. For real‑time monitoring use top.

Basic options:

-A: show all processes (same as -e)

-a: show processes attached to terminals, including those of other users

-u: display information in a user‑oriented format

x: usually combined with -a to list processes without a controlling terminal

Output format options:

l: long, detailed listing of each PID

j: jobs format

-f: full‑format listing

2. What does ps output without parameters?

Running ps with no arguments displays four columns: PID, TTY, TIME, and CMD. The rows are not sorted.

3. How to display all current processes?

Use the -a option (all) and optionally x to include processes without a controlling terminal. $ ps -ax You can pipe the output to less for easier navigation.

4. How to filter by user?

Use -u followed by the username. Example for user pungki:

$ ps -u pungki

5. How to filter by CPU and memory usage?

Use the aux options to display comprehensive information: $ ps -aux | less Sort by CPU usage (descending):

$ ps -aux --sort -pcpu | less

Sort by memory usage (descending):

$ ps -aux --sort -pmem | less

Combine both sorts and show the top 10 results:

$ ps -aux --sort -pcpu,+pmem | head -n 10

6. How to filter by process name or PID?

Use -C followed by the command name. Example for the getty process: $ ps -C getty For more detail add -f:

$ ps -f -C getty

7. How to filter by thread?

Use -L with the PID of the process whose threads you want to list:

$ ps -L 1213

8. How to display processes as a tree?

Use the -axjf options for a tree‑like view, or the dedicated pstree command:

$ ps -axjf
$ pstree

9. How to show security information?

Display who is logged in and what they are running:

$ ps -eo pid,user,args
-e

shows all processes; -o controls the output columns (PID, User, Args).

10. How to format output for processes created by root?

Filter by real and effective UID of root and use the user‑oriented format:

$ ps -U root -u root u

11. How to monitor processes in real time with ps?

Combine ps with watch to refresh every second:

$ watch -n 1 'ps -aux --sort -pmem, -pcpu'

Limit to the top 20 lines:

$ watch -n 1 'ps -aux --sort -pmem, -pcpu | head 20'

Filter for a specific user (e.g., pungki) while watching:

$ watch -n 1 'ps -aux -U pungki u --sort -pmem, -pcpu | head 20'

12. Conclusion

The ps command is versatile for generating custom reports; it is installed by default on all Linux distributions. Remember to consult man ps for a complete list of options.

Source: https://juejin.im/post/5bf9213ce51d452237153c5c
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.

psShell Commandsprocess monitoring
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

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.