ฮป
clion
+
+
+
+
gradle
+
+
===
gatsby
gh
symfony
+
+
+
asm
jenkins
gentoo
tf
grafana
+
_
+
@
phoenix
elasticsearch
<=
+
bsd
+
+
+
express
+
centos
+
+
+
+
+
+
solid
+
+
{}
intellij
+
zig
+
+
adonis
+
gitlab
+
gh
wasm
+
+
ray
cargo
+
webstorm
+
+
+
+
+
~
+
dns
+
+
+
gin
+
soap
fastapi
+
+
tf
+
ios
deno
css
+
+
hack
nest
+
Back to Blog
๐Ÿ“Š Monitoring Running Processes: Simple Guide
Alpine Linux Process Monitoring System Admin

๐Ÿ“Š Monitoring Running Processes: Simple Guide

Published Jun 4, 2025

Easy tutorial for monitoring processes in Alpine Linux. Perfect for beginners with step-by-step instructions and clear examples.

9 min read
0 views
Table of Contents

๐Ÿ“Š Monitoring Running Processes: Simple Guide

Want to see whatโ€™s happening on your system? Letโ€™s learn to monitor processes! ๐Ÿ’ป This guide shows you easy ways to watch running programs. Your system will have no secrets! ๐Ÿ˜Š

๐Ÿค” What are Running Processes?

Running processes are all the programs working on your computer right now. Think of them like busy workers in a factory!

Running processes are like:

  • ๐Ÿ“ Workers doing different jobs in your computer
  • ๐Ÿ”ง Programs that keep your system running smoothly
  • ๐Ÿ’ก Tasks that happen behind the scenes

๐ŸŽฏ What You Need

Before we start, you need:

  • โœ… Alpine Linux system with terminal access
  • โœ… Basic knowledge of command line
  • โœ… A few minutes to practice
  • โœ… Curiosity about what your system does

๐Ÿ“‹ Step 1: Basic Process Viewing

See All Running Processes

Letโ€™s look at whatโ€™s running on your system. Itโ€™s easy! ๐Ÿ˜Š

What weโ€™re doing: Looking at all the programs currently running.

# Show all running processes
ps aux

# Show processes in a tree format
ps auxf

# Show just your processes
ps aux | grep $USER

What this does: ๐Ÿ“– Shows you every program running right now.

Example output:

USER       PID  %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1   0.0  0.3   1234   567 ?        Ss   10:00   0:01 /sbin/init
root       123   0.1  0.5   2345  1012 ?        S    10:01   0:00 [kthreadd]
user      1234   2.3  1.2   3456  2034 pts/0    R+   10:05   0:03 vim file.txt

What this means: You can see every program and how much memory it uses! โœ…

๐Ÿ’ก Important Tips

Tip: The PID number is like each processโ€™s ID card! ๐Ÿ’ก

Warning: Donโ€™t kill important system processes! โš ๏ธ

๐Ÿ› ๏ธ Step 2: Real-time Process Monitoring

Watch Processes Live

Now letโ€™s watch processes update in real time. Donโ€™t worry - itโ€™s still easy! ๐Ÿ˜Š

What weโ€™re doing: Watching processes change live, like a dashboard.

# Show live process activity
top

# Better version with colors
htop

# Simple system monitor
watch -n 1 'ps aux | head -10'

# Monitor specific processes
watch -n 2 'ps aux | grep nginx'

Code explanation:

  • top: Shows live process list with CPU and memory usage
  • htop: Prettier version of top with colors and mouse support
  • watch -n 1: Refreshes the command every 1 second
  • grep nginx: Filters to show only nginx processes

Expected Output:

top - 10:15:30 up 2:45, 1 user, load average: 0.15, 0.20, 0.18
Tasks: 45 total, 1 running, 44 sleeping
%Cpu(s): 2.3 us, 1.2 sy, 0.0 ni, 96.5 id
KiB Mem: 1024000 total, 512000 free, 256000 used, 256000 buff/cache

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
 1234 user      20   0   15.1m   8.2m   4.5m S   2.3  0.8   0:03.45 vim

What this means: Great job! Youโ€™re watching your system work live! ๐ŸŽ‰

Create Process Monitoring Scripts

What weโ€™re doing: Making simple scripts to watch important processes.

# Create a process monitor script
cat > /usr/local/bin/process-monitor.sh << 'EOF'
#!/bin/bash
# Simple Process Monitor

echo "๐Ÿ–ฅ๏ธ  Alpine Linux Process Monitor"
echo "=============================="
echo "Date: $(date)"
echo ""

# Show system load
echo "๐Ÿ“Š System Load:"
uptime

echo ""

# Show top 5 CPU processes
echo "๐Ÿ”ฅ Top 5 CPU Users:"
ps aux --sort=-%cpu | head -6

echo ""

# Show top 5 memory processes
echo "๐Ÿ’พ Top 5 Memory Users:"  
ps aux --sort=-%mem | head -6

echo ""

# Show process count
echo "๐Ÿ“ˆ Process Statistics:"
echo "Total processes: $(ps aux | wc -l)"
echo "Running processes: $(ps aux | grep -c ' R ')"
echo "Sleeping processes: $(ps aux | grep -c ' S ')"
EOF

chmod +x /usr/local/bin/process-monitor.sh

# Test the monitor
/usr/local/bin/process-monitor.sh

What this does: Creates your own process monitoring dashboard! ๐ŸŒŸ

๐ŸŽฎ Letโ€™s Try It!

Time for hands-on practice! This is the fun part! ๐ŸŽฏ

What weโ€™re doing: Testing our process monitoring skills.

# Start a test process in background
sleep 300 &
echo "Started background process: $!"

# Find our test process
ps aux | grep sleep

# Monitor it
top -p $!

# When done, stop it
kill $!

You should see:

Started background process: 1234
user      1234  0.0  0.0   1234   456 pts/0    S    10:10   0:00 sleep 300

Awesome work! ๐ŸŒŸ

๐Ÿ“Š Quick Summary Table

CommandPurposeWhat it Shows
๐Ÿ”ง ps auxList all processesCurrent running programs
๐Ÿ› ๏ธ topLive monitoringReal-time system activity
๐ŸŽฏ htopBetter live viewColorful process dashboard
๐Ÿ“Š watch psRefresh viewUpdated process list

๐ŸŽฎ Practice Time!

Letโ€™s practice what you learned! Try these simple examples:

Example 1: Find Heavy Processes ๐ŸŸข

What weโ€™re doing: Finding processes that use lots of CPU or memory.

# Find processes using most CPU
echo "๐Ÿ”ฅ CPU Heavy Processes:"
ps aux --sort=-%cpu | head -5

# Find processes using most memory
echo "๐Ÿ’พ Memory Heavy Processes:"
ps aux --sort=-%mem | head -5

# Find processes by name
echo "๐Ÿ” Web Server Processes:"
ps aux | grep -E "(nginx|apache|httpd)"

# Count processes by user
echo "๐Ÿ‘ฅ Processes by User:"
ps aux | awk '{print $1}' | sort | uniq -c | sort -nr

What this does: Shows you which programs are working hardest! ๐ŸŒŸ

Example 2: Process Health Check ๐ŸŸก

What weโ€™re doing: Creating a health check for important services.

# Create service health checker
cat > /usr/local/bin/service-health.sh << 'EOF'
#!/bin/bash
# Service Health Checker

echo "๐Ÿฅ Service Health Check"
echo "====================="

# Check important services
services=("sshd" "chronyd" "networking")

for service in "${services[@]}"; do
    if pgrep "$service" > /dev/null; then
        echo "โœ… $service: Running (PID: $(pgrep $service))"
    else
        echo "โŒ $service: Not running"
    fi
done

echo ""

# Check system resources
echo "๐Ÿ“Š System Resources:"
echo "Load: $(uptime | awk -F'load average:' '{print $2}')"
echo "Memory: $(free | grep Mem | awk '{printf "%.1f%%", $3/$2 * 100.0}')"
echo "Processes: $(ps aux | wc -l)"
EOF

chmod +x /usr/local/bin/service-health.sh

# Run the health check
/usr/local/bin/service-health.sh

What this does: Creates an automatic system health checker! ๐Ÿ“š

๐Ÿšจ Fix Common Problems

Problem 1: Too many processes running โŒ

What happened: Your system is slow because too many programs are running. How to fix it: Find and stop unnecessary processes!

# Find processes using most resources
ps aux --sort=-%cpu | head -10

# Stop a specific process safely
kill -TERM 1234

# If it won't stop, force it
kill -KILL 1234

Problem 2: Canโ€™t find a specific process โŒ

What happened: You know a program is running but canโ€™t see it. How to fix it: Use better search methods!

# Search by name
pgrep -f "program-name"

# Search with more details
ps aux | grep -i "program"

# Find by port (if it's a server)
netstat -tulpn | grep :80

Problem 3: Process information is confusing โŒ

What happened: Process output has too much information. How to fix it: Use simpler formats!

# Simple process list
ps -eo pid,user,cmd

# Just running processes
ps r

# Custom format
ps -eo pid,ppid,%cpu,%mem,cmd --sort=-%cpu

Donโ€™t worry! Process monitoring takes practice. Youโ€™re doing great! ๐Ÿ’ช

๐Ÿ’ก Simple Tips

  1. Start with simple commands ๐Ÿ“… - Use ps aux first
  2. Learn one tool well ๐ŸŒฑ - Master top or htop
  3. Watch regularly ๐Ÿค - Check your system often
  4. Donโ€™t panic ๐Ÿ’ช - High CPU usage is often normal

โœ… Check Everything Works

Letโ€™s make sure everything is working:

# Test basic monitoring
echo "Testing process monitoring..."

# Check ps command
ps aux > /dev/null && echo "โœ… ps command works"

# Check if top is available  
which top > /dev/null && echo "โœ… top command available"

# Check our custom scripts
ls -la /usr/local/bin/*monitor* /usr/local/bin/*health* 2>/dev/null

# Run a quick process check
echo "Current process count: $(ps aux | wc -l)"

echo "Process monitoring test completed! โœ…"

Good output:

Testing process monitoring...
โœ… ps command works
โœ… top command available
-rwxr-xr-x 1 root root 1234 Jun  4 10:15 /usr/local/bin/process-monitor.sh
-rwxr-xr-x 1 root root 2345 Jun  4 10:20 /usr/local/bin/service-health.sh
Current process count: 47
Process monitoring test completed! โœ…

๐Ÿ† What You Learned

Great job! Now you can:

  • โœ… View all running processes on your system
  • โœ… Monitor processes in real-time with top and htop
  • โœ… Create custom monitoring scripts
  • โœ… Find and troubleshoot problematic processes!

๐ŸŽฏ Whatโ€™s Next?

Now you can try:

  • ๐Ÿ“š Learning about process priorities and nice values
  • ๐Ÿ› ๏ธ Setting up automated process monitoring alerts
  • ๐Ÿค Creating process management scripts
  • ๐ŸŒŸ Building system dashboards with process information!

Remember: Every system administrator was once a beginner. Youโ€™re doing amazing! ๐ŸŽ‰

Keep practicing and youโ€™ll become a process monitoring expert too! ๐Ÿ’ซ