Quick Tip
Master `ps` Output with Custom `awk` Formatting
Challenge: The default output of the ps command can be verbose and difficult to parse for specific process information. You often need to sift through a lot of columns to find what you’re looking for.
The Solution: Use awk to selectively display and format the output of ps for key process details.
ps aux | awk '{printf "%-10s %-30s %s\n", $2, $11, $4}'
Why it works: This command pipes the output of ps aux (which shows all processes for all users with detailed information) to awk. awk then formats the output, displaying only the Process ID (PID) in the first column, the command name in the second, and the CPU usage percentage in the third, creating a cleaner, more readable list.
Pro-Tip: To see processes sorted by CPU usage, pipe the output to sort -rnk 3 after the awk command.
Linux Tips & Tricks | © ngelinux.com | 5/8/2026
