Quick Tip
Taming `ps` Output: Focused Process Info with `awk`
Challenge: The `ps` command can produce an overwhelming amount of output, making it difficult to quickly find specific process information like the full command line, parent process ID, or CPU/memory usage.
The Solution: Leverage `awk` to precisely filter and format the output of `ps` to display only the columns you need.
ps aux | awk '{print "PID:", $2, "User:", $1, "CPU:", $3 "%", "MEM:", $4 "%", "CMD:", $11}'
Why it works: `ps aux` lists all processes with user-oriented format. `awk` then processes each line, printing specific fields (like PID, User, CPU, MEM, and the command itself, which starts at field 11 in this common output) with custom labels.
Pro-Tip: Use `ps -eo pid,ppid,cmd,%cpu,%mem –sort=-%cpu | head` to sort processes by CPU usage and see the top consumers.
Linux Tips & Tricks | © ngelinux.com | 6/22/2026
