Site icon New Generation Enterprise Linux

Master Your `ps` Output with `awk` for Focused Process Info

Quick Tip

Master Your `ps` Output with `awk` for Focused Process Info

Challenge: The output of the `ps` command can be overwhelming when you’re trying to quickly identify specific processes by name or user. Filtering through endless lines of process information is inefficient.

The Solution: Pipe the output of `ps aux` to `awk` to filter and format it. For instance, to see only processes owned by the user ‘nginx’ and display just the PID, TTY, and command:

ps aux | awk '/nginx/ {print $2, $11}'

Why it works: `awk` allows you to define patterns to match lines (in this case, lines containing ‘nginx’) and then specify which fields (columns) to print from those matching lines. Field $2 is the PID, and field $11 is typically the command name.

Pro-Tip: Use `ps aux | awk ‘{print $1, $2, $11}’` to display the user, PID, and command for all processes, providing a more structured overview.

Linux Tips & Tricks | © ngelinux.com | 6/7/2026

0 0 votes
Article Rating
Exit mobile version