Quick Tip
Master `ps` Output with Custom `awk` Formatting
Challenge: The output of the `ps` command can be overwhelming and often contains more information than you need. Extracting specific process details can be tedious and error-prone using basic filtering.
The Solution: Leverage `awk` to precisely select and format the columns you want from the `ps` command, making process monitoring significantly more efficient.
ps aux | awk '{print $2, $11}'
Why it works: This command pipes the output of `ps aux` (which shows all processes with user, CPU, memory, etc.) to `awk`. `awk` then processes each line, printing only the second column (PID) and the eleventh column (command name), effectively cleaning up the output to show only the essential information.
Pro-Tip: For even more control, you can specify custom headers using `awk`’s `BEGIN` block and conditionally print lines based on process name or user. For example: ps aux | awk 'BEGIN {print "PID\tCOMMAND"} $2 ~ /nginx/ {print $2 "\t" $11}' to only show Nginx processes.
Linux Tips & Tricks | © ngelinux.com | 5/12/2026
