Site icon New Generation Enterprise Linux

Mastering `ps` Output: Focused Process Info with `awk`

Quick Tip

Mastering `ps` Output: Focused Process Info with `awk`

Challenge: The `ps` command provides a wealth of information about running processes, but it can be overwhelming to sift through for specific details. Often, you only need a few key pieces of information, like the PID, CPU usage, and command name.

The Solution: Combine `ps` with `awk` to precisely select and format the columns you need.

ps aux | awk '{print $1, $3, $4, $11}'

Why it works: `ps aux` lists all processes with detailed information. `awk` then processes this output line by line, printing only the fields corresponding to username ($1), CPU usage ($3), memory usage ($4), and the command name ($11). This effectively filters and formats the output to your specific needs.

Pro-Tip: To sort processes by CPU usage in descending order, pipe the output to `sort -rnk2` (assuming CPU usage is the second column after awk).

Linux Tips & Tricks | © ngelinux.com | 6/18/2026

0 0 votes
Article Rating
Exit mobile version