Quick Tip
Streamline `ps` Output with `awk` for Focused Process Info
Challenge: When listing processes with `ps`, the output can be overwhelming with unnecessary columns, making it hard to find the specific information you need quickly, like a process’s CPU or memory usage.
The Solution: Use `awk` to filter and format the `ps` output to display only the columns you care about.
ps aux | awk '{print $2, $3, $4, $11}'
Why it works: The `ps aux` command lists all processes with user, CPU, memory, and command details. `awk` then processes this output line by line, printing only the fields specified by their column number ($2 for PID, $3 for %CPU, $4 for %MEM, and $11 for the command name in this common `ps aux` output format). You can adjust the column numbers to display different information.
Pro-Tip: To display only the PID and command name, use ps aux | awk '{print $2, $11}'.
Linux Tips & Tricks | © ngelinux.com | 7/3/2026
