Site icon New Generation Enterprise Linux

Master Process Monitoring with `ps` and `awk`

Quick Tip

Master Process Monitoring with `ps` and `awk`

Challenge: The default output of the ps command can be overwhelming, especially when you need to quickly find specific information about running processes, such as CPU usage, memory consumption, or command names, from a particular user.

The Solution: Leverage the power of `awk` to filter and format the output of ps for precise process monitoring.

ps aux | awk '/myuser/ { print $1, $2, $3, $4, $11 }'

Why it works: This command first lists all processes with user information (aux). Then, `awk` filters lines containing ‘myuser’ (replace with the actual username) and prints specific columns: User, PID, %CPU, %MEM, and the command. You can easily adjust the column numbers to display any information you need.

Pro-Tip: For even more focused output, use ps -eo user,pid,%cpu,%mem,cmd --sort=-%cpu | head -n 10 to see the top 10 CPU-consuming processes.

Linux Tips & Tricks | © ngelinux.com | 5/17/2026

0 0 votes
Article Rating
Exit mobile version