Quick Tip
Master Your `ps` Output with `awk` for Focused Process Info
Challenge: The output of the `ps` command can be overwhelming, listing numerous processes with many columns of information. It’s often difficult to quickly find specific details you’re looking for, like CPU usage or memory consumption for a particular process.
The Solution: Combine `ps` with `awk` to precisely extract and display only the columns you need, making process monitoring much more efficient.
ps aux | awk '{print $1, $2, $4, $11}'
Why it works: `ps aux` provides a comprehensive list of running processes. `awk` then processes this output line by line, and `{print $1, $2, $4, $11}` tells it to print only the 1st (User), 2nd (PID), 4th (CPU%), and 11th (Command) fields. You can adjust these field numbers to display other data like memory usage ($6), virtual memory size ($5), etc.
Pro-Tip: To sort your processes by CPU usage in descending order, pipe the output to `sort -rnk 3` (assuming CPU% is the 3rd column in your awk output). For example: ps aux | awk '{print $1, $2, $4, $11}' | sort -rnk 3
Linux Tips & Tricks | © ngelinux.com | 6/20/2026
