๐ System Resource Monitoring with top and htop in AlmaLinux: Beginnerโs Guide
Is your AlmaLinux system running slow? Want to see whatโs using all your CPU or memory? ๐ค Letโs learn how to monitor your system like a pro using top
and htop
! These tools show you everything happening in your computer in real-time. Itโs like having X-ray vision for your system! ๐๏ธโจ
๐ค Why is System Monitoring Important?
Keeping an eye on your system helps you catch problems before they get serious! Hereโs why monitoring rocks:
- ๐ Find Slow Programs - See whatโs making your system sluggish
- ๐พ Memory Management - Know when youโre running out of RAM
- ๐ฅ CPU Usage - Identify programs hogging your processor
- ๐ Catch Problems Early - Spot issues before crashes
- ๐ Performance Tuning - Make your system run faster
- ๐ก๏ธ Security - Detect suspicious processes
๐ฏ What You Need
Before we start monitoring, make sure you have:
- โ AlmaLinux system running
- โ Terminal access
- โ Basic command line skills
- โ 5 minutes to learn
- โ Curiosity about your system!
๐ Step 1: Using the top Command
top
is installed by default and shows live system info! ๐บ
Start top
# Simply type:
top
# Or with options:
top -u username # Show only one user's processes
top -p 1234 # Monitor specific process ID
Example output:
top - 14:30:25 up 5 days, 3:15, 2 users, load average: 0.15, 0.20, 0.18
Tasks: 125 total, 1 running, 124 sleeping, 0 stopped, 0 zombie
%Cpu(s): 2.5 us, 1.0 sy, 0.0 ni, 96.5 id, 0.0 wa, 0.0 hi, 0.0 si
MiB Mem: 7821.0 total, 2145.3 free, 3421.7 used, 2254.0 buff/cache
MiB Swap: 2048.0 total, 2048.0 free, 0.0 used, 3987.2 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1234 john 20 0 512000 45236 8920 S 5.3 0.6 12:34.56 firefox
5678 root 20 0 225544 11240 7832 S 2.0 0.1 1:23.45 systemd
What this shows: ๐
load average
= System load (lower is better)%Cpu(s)
= CPU usage breakdownMiB Mem
= Memory usagePID
= Process ID number%CPU
= CPU usage per process%MEM
= Memory usage per process
Keyboard Shortcuts in top
# While top is running, press:
h # Help menu
q # Quit top
k # Kill a process
r # Renice (change priority)
M # Sort by memory usage
P # Sort by CPU usage
1 # Show individual CPU cores
c # Show full command paths
๐ง Step 2: Installing and Using htop
htop
is like top but prettier and easier! ๐
Install htop
# Install htop
sudo dnf install -y htop
# Verify installation
htop --version
Start htop
# Just type:
htop
# Or with options:
htop -u username # Show specific user
htop -t # Tree view (shows parent/child)
Pro tip: ๐ก htop uses colors! Green = normal, red = kernel, blue = low priority
๐ Step 3: Understanding the Display
Letโs decode what youโre seeing! ๐
CPU Meters
# In htop, CPU bars show:
[|||||||| ] 80% # Green = user processes
[|| ] 20% # Red = system/kernel
[| ] 10% # Blue = low priority
# Multiple cores shown as:
1 [|||| ] 40%
2 [||||||||||] 100% # This core is maxed out!
3 [|| ] 20%
4 [||| ] 30%
Memory Bar
# Memory display:
Mem[||||||||||||| ] 4.2G/8.0G # Green = used
Swp[ ] 0K/2.00G # Yellow = cache
Process List
# Columns explained:
PID # Process ID (unique number)
USER # Who owns the process
PRI # Priority (lower = higher priority)
NI # Nice value (process politeness)
VIRT # Virtual memory size
RES # Physical RAM used
SHR # Shared memory
S # State (S=sleeping, R=running)
CPU% # CPU usage percentage
MEM% # Memory usage percentage
TIME+ # Total CPU time used
Command # What's running
โ Step 4: Common Monitoring Tasks
Letโs do some real monitoring! ๐ฏ
Find Memory Hogs
# In htop, press:
F6 # Sort menu
โ # Arrow down to MEM%
Enter # Sort by memory
# Or in top:
M # Sort by memory instantly
Kill Problematic Process
# In htop:
# 1. Arrow keys to select process
# 2. Press F9 for kill menu
# 3. Choose signal (usually 15 SIGTERM)
# 4. Press Enter
# In top:
k # Press k
[PID] # Enter process ID
[signal] # Press Enter for default (15)
Monitor Specific Program
# Watch Firefox only:
top -p $(pgrep firefox)
# Or in htop:
F4 # Filter
firefox # Type program name
Enter # Apply filter
๐ฎ Quick Examples
Example 1: Check Whatโs Slowing You Down ๐
# Start htop
htop
# Press F6 (Sort)
# Select CPU%
# Press Enter
# Now you see the CPU hogs at the top!
# If something uses 100% CPU constantly, that's your problem!
Example 2: Monitor During Heavy Task ๐ช
# Open two terminals
# Terminal 1: Start monitoring
htop
# Terminal 2: Run heavy task
tar -czf backup.tar.gz /large/directory
# Watch htop to see:
# - CPU spike during compression
# - Memory usage increase
# - Disk I/O activity
Example 3: Create Monitoring Script ๐
# Create monitor.sh
nano ~/monitor.sh
#!/bin/bash
echo "=== System Health Check ==="
echo "Date: $(date)"
echo ""
echo "Memory Usage:"
free -h
echo ""
echo "CPU Load:"
uptime
echo ""
echo "Top 5 CPU processes:"
ps aux | sort -rk 3,3 | head -6
echo ""
echo "Top 5 Memory processes:"
ps aux | sort -rk 4,4 | head -6
# Make executable
chmod +x ~/monitor.sh
# Run it
./monitor.sh
๐จ Fix Common Problems
Problem 1: System very slow โ
Symptoms:
- Everything takes forever
- Mouse barely moves
- Canโt open programs
Try this:
# Quick check in terminal
top -b -n 1 | head -20
# Look for:
# - Load average > number of CPUs
# - CPU% near 100%
# - Memory full
# Emergency fix:
killall firefox # Or whatever's using most resources
Problem 2: Canโt see all processes โ
Try this:
# Run as root to see everything
sudo htop
# In top, toggle views:
V # Forest view (tree)
H # Show threads
u # Filter by user
Problem 3: Numbers changing too fast โ
Slow down the refresh:
# In top:
d # Change delay
3 # Enter 3 seconds
Enter # Apply
# Start htop with slower refresh:
htop -d 30 # Update every 3 seconds
๐ Simple Commands Summary
Task | Command |
---|---|
๐ Start top | top |
๐ Start htop | htop |
๐ Refresh | Space (in htop) |
๐พ Sort by memory | M (top) or F6 (htop) |
๐ฅ Sort by CPU | P (top) or F6 (htop) |
โ Kill process | k (top) or F9 (htop) |
๐ Search | F3 (htop) |
๐ช Quit | q (both) |
๐ก Tips for Success
- Check Regularly ๐ - Monitor weekly to know whatโs normal
- Learn Your Baseline ๐ - Know your systemโs usual numbers
- Donโt Panic ๐ - High CPU/memory isnโt always bad
- Use Colors ๐จ - htopโs colors make things clearer
- Take Screenshots ๐ธ - Save output when debugging
๐ What You Learned
Youโre now a monitoring master! You can:
- โ Use top to monitor system resources
- โ Navigate htopโs colorful interface
- โ Find resource-hungry processes
- โ Kill problematic programs safely
- โ Sort and filter process lists
- โ Understand CPU and memory usage
๐ฏ Why This Matters
Now you can:
- ๐ Keep your system running smoothly
- ๐ Diagnose performance problems quickly
- ๐พ Manage memory usage effectively
- ๐ก๏ธ Spot suspicious activity
- ๐ Optimize system performance
- ๐ Debug issues like a pro
Remember: Regular monitoring prevents big problems! Check your system weekly and youโll catch issues early! โญ
Happy monitoring! Your AlmaLinux system is now under your watchful eye! ๐๏ธ๐