Quick Tip
Master Process Monitoring with `ps` and `awk`
Challenge: You need to quickly identify specific processes running on your Linux system, but the default `ps` output is too verbose and difficult to filter for the exact information you need.
The Solution: Combine the power of `ps` with `awk` for precise process filtering and custom output formatting.
ps aux | awk '{if ($1 ~ /root/ && $11 ~ /nginx/) print $2, $11}'
Why it works: This command lists all processes (`ps aux`), then pipes the output to `awk`. `awk` then filters for lines where the first field (user) is “root” and the eleventh field (command) contains “nginx”, finally printing only the process ID (field 2) and the command name (field 11).
Pro-Tip: Use `grep` for simpler pattern matching, e.g., `ps aux | grep nginx`, but `awk` offers much more flexibility for complex conditions and custom output.
Linux Tips & Tricks | © ngelinux.com | 5/17/2026
