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

Quick Tip

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

Challenge: The output of the `ps` command can be overwhelming, especially on busy systems. Extracting specific process information can be tedious and time-consuming.

The Solution: Combine `ps` with `awk` to filter and format the output precisely as you need it.

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

Why it works: `ps aux` provides a detailed snapshot of all running processes. `awk ‘$1 == “root” { print $2, $11 }’` then filters this output to only show lines where the first field (user) is “root”, and prints the second field (PID) and eleventh field (command name).

Pro-Tip: Use `ps -eo pid,ppid,cmd,%mem,%cpu –sort=-%cpu | head -n 10` to quickly see the top 10 CPU-consuming processes.

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

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted