Taming `ps` Output with `awk` for Focused Process Info
Quick Tip
Taming `ps` Output with `awk` for Focused Process Info
Challenge: The output of the `ps` command can be overwhelming, especially on busy systems. It’s often difficult to quickly extract specific information about processes, like their parent process ID (PPID) or CPU utilization.
The Solution: Leverage the power of `awk` to filter and format the output of `ps` for precise process monitoring.
ps aux | awk '$1 ~ /root/ {print $2, $11}'
Why it works: This command pipes the output of `ps aux` (which shows all processes for all users) to `awk`. `awk` then filters lines where the first column (`$1`, the user) matches “root” and prints the process ID (`$2`) and the command name (`$11`). This allows you to quickly see all processes owned by the root user and their associated commands.
Pro-Tip: You can easily modify the `awk` condition to filter by other users, process names, or display different columns like CPU usage (`$3`) or memory usage (`$4`) by changing the field numbers. For example, to see only the PID and CPU usage of processes containing “nginx” in their command name: ps aux | awk '/nginx/ {print $2, $3}'
Linux Tips & Tricks | © ngelinux.com | 6/23/2026
