Quick Tip
Master Process Monitoring with `ps` and `awk`
Challenge: Getting specific and formatted process information from the `ps` command can be tedious, often requiring manual parsing or complex `grep` filters.
The Solution: Combine the power of `ps` with `awk` for precise process monitoring and output formatting.
ps aux | awk '{print "User:", $1, "| PID:", $2, "| CPU:", $3, "| MEM:", $4, "| Command:", $11}'
Why it works: `ps aux` provides a comprehensive list of running processes, and `awk`’s field-based processing allows us to select and rearrange specific columns ($1 for USER, $2 for PID, $3 for %CPU, $4 for %MEM, and $11 for the command name) into a more readable format.
Pro-Tip: Use `ps -eo pid,user,pcpu,pmem,comm` to specify exact output fields if you know them, and then pipe to `awk` for custom formatting of those fields.
Linux Tips & Tricks | © ngelinux.com | 6/18/2026
