Monitor and manage processes with ps, top, htop, and signals
✓Works with OpenClaudeYou are a Linux system administrator. The user wants to monitor and manage running processes using ps, top, htop, and process signals (SIGTERM, SIGKILL, etc.).
What to check first
- Run
ps auxto see if basic process listing works on your system - Check if
topandhtopare installed withwhich topandwhich htop(htop may need installation viaapt install htoporyum install htop)
Steps
- Use
ps auxto list all running processes with full details — the output shows USER, PID, CPU%, MEM%, COMMAND columns essential for identification - Filter processes by name with
ps aux | grep nginxto find specific processes (add-v grepto exclude the grep command itself) - View process hierarchy and parent-child relationships with
ps -ef --forestto understand dependencies - Sort processes by memory usage with
ps aux --sort=-%mem | head -20to identify memory hogs - Launch
topfor real-time monitoring — pressqto quit,Mto sort by memory,Pto sort by CPU,kto kill a process interactively - Use
htopfor a more user-friendly interface with color coding — arrow keys navigate,F9sends signals,F10quits - Send signals to processes with
kill -SIGTERM <PID>(graceful shutdown) orkill -SIGKILL <PID>(force kill, PID 9) - Use
pkill -f "process_name"to kill all processes matching a pattern without needing the exact PID
Code
#!/bin/bash
# Linux Process Monitoring and Management Script
# Function 1: List all processes sorted by memory usage
list_by_memory() {
echo "=== Top 10 processes by memory usage ==="
ps aux --sort=-%mem | head -11
}
# Function 2: Find process by name
find_process() {
local process_name=$1
echo "=== Searching for process: $process_name ==="
ps aux | grep -E "^|$process_name" | grep -v grep
}
# Function 3: Show process tree for a specific process
show_process_tree() {
local process_name=$1
echo "=== Process tree for $process_name ==="
ps -ef --forest | grep -E "^|$process_name" | head -20
}
# Function 4: Monitor CPU usage in real-time
monitor_cpu() {
echo "=== Top 5 CPU consumers (updates every 2 seconds, press Ctrl+C to exit) ==="
watch -n 2 'ps aux --sort=-%cpu | head -6'
}
# Function 5: Send signal to process by name
kill_process() {
local process_name=$1
local signal=${2:-SIGTERM}
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Linux Skills
Other Claude Code skills in the same category — free to download.
Linux Bash Script
Write Bash scripts with variables, loops, and error handling
Linux Systemd
Create and manage systemd services and timers
Linux Networking
Configure Linux networking with iptables, DNS, and SSH
Linux Permissions
Manage file permissions, ownership, and ACLs
Linux Disk
Manage disks, partitions, LVM, and filesystem mounts
Linux systemd Service Setup
Create a production-grade systemd service with logging, restart, and security hardening
Linux Performance Profiling
Find performance bottlenecks on Linux with perf, strace, and bpftrace
Want a Linux skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.