Site icon New Generation Enterprise Linux

Tame Your `ps` Output: Focused Process Info with `awk`

Quick Tip

Tame Your `ps` Output: Focused Process Info with `awk`

Challenge: The `ps` command can be incredibly verbose, making it difficult to quickly find specific information about running processes. You often end up piping it to `grep` repeatedly, which isn’t always the most efficient.

The Solution: Leverage the power of `awk` to filter and format `ps` output on the fly, extracting exactly what you need.

ps aux | awk '$1 == "root" { print $2, $11 }'

Why it works: This command lists all processes (`aux`), then uses `awk` to filter for lines where the first field (`$1`, the user) is “root”. It then prints the second field (`$2`, the PID) and the eleventh field (`$11`, the command name).

Pro-Tip: Combine this with other `awk` conditions to filter by memory usage, CPU percentage, or even process state. For example, `ps aux | awk ‘$4 > 5.0 { print $2, $4, $11 }’` to see processes using more than 5% CPU.

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

0 0 votes
Article Rating
Exit mobile version