Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bash Process Scripts

Three bash scripts that use ps aux, grep, sort, and head to inspect and filter running processes on a Linux/Unix system.

Scripts

user_process.sh — Lists all processes running under the current user.

user_process_sorted.sh — Same as above, but asks whether to sort by memory or CPU usage.

user_process_top.sh — Same as above, plus asks how many processes to display (top N).

Usage

chmod +x user_process.sh user_process_sorted.sh user_process_top.sh

./user_process.sh
./user_process_sorted.sh
./user_process_top.sh

Key commands used

Command Purpose
ps aux List all running processes with CPU, memory, and user info
grep "^$USER" Filter to only the current user's processes
sort -k4 -rn Sort by a column (e.g. column 4 = %MEM) in descending numeric order
head -n N Limit output to the top N lines
read -p Prompt the user for input

When does ps aux actually matter?

These aren't academic exercises — ps aux is one of the most-used commands in real operations work. Situations where it's the first thing someone runs:

  • Server is slow or unresponsive — sort by CPU to find the process eating all the compute: ps aux | sort -k3 -rn | head -n 5
  • Running out of memory — sort by memory to find the culprit: ps aux | sort -k4 -rn | head -n 5
  • Disk filling up from logs — grep for the suspected process to confirm it's still running and check how long it's been going
  • Deploy went wrong — check if the old version of an app is still running alongside the new one
  • Zombie processes accumulatingps aux | grep Z to find dead processes whose parents never reaped them
  • "Who left this running?" — on shared dev servers, find the intern's forgotten Jupyter notebook eating 12GB of RAM

In all of these, ps aux is step one: see what's running, find the problem, fix it.

What I learned

See learning_notes.md for a full breakdown of every concept explored while building these scripts.

About

Bash scripts for monitoring and sorting user processes by CPU usage and memory

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages