Site icon New Generation Enterprise Linux

Streamline Process Monitoring with `ps` and `awk`

Quick Tip

Streamline Process Monitoring with `ps` and `awk`

Challenge: You often need to quickly find specific processes or extract particular information from the output of the ps command, which can be verbose and difficult to parse manually.

The Solution: Combine the power of ps with awk to filter and format process information on the fly.

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

Why it works: The ps aux command provides a comprehensive list of running processes. Piping this output to awk allows you to filter lines that match ‘your_pattern’ and then precisely select, reorder, and format the desired columns (e.g., user, PID, command name).

Pro-Tip: Use ps -ef for a slightly different output format, or pipe to grep first for simpler filtering before awk for more complex data extraction. For example, to find all processes owned by ‘root’ and print their PID and command: ps aux | grep '^root' | awk '{print $2, $11}'

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

0 0 votes
Article Rating
Exit mobile version