Free Top Resource Monitoring - ryzendew/Linux-Tips-and-Tricks GitHub Wiki
Free & Top System Resource Monitoring for Beginners
Table of Contents
- :pencil: What are free and top?
- :zap: FREE Commands
- :desktop: TOP Commands
- :bulb: Common Troubleshooting
- Check Memory Usage
- Find High CPU Processes
- Find High Memory Processes
- Monitor Memory Continuously
- Check System Load
:pencil: What are free and top?
freeshows memory (RAM) usage informationtopdisplays real-time system resource usage (CPU, memory, processes)- Essential tools for monitoring system performance
- Both are usually pre-installed on Linux systems
What free can do:
- Show total, used, and free memory
- Display swap usage
- Show buffer and cache usage
- Help identify memory issues
What top can do:
- Display real-time CPU and memory usage
- Show running processes
- Sort processes by resource usage
- Kill processes
- Monitor system load
:zap: FREE Commands
Show Memory Usage
free
What this does:
- Shows memory usage in kilobytes
- Displays total, used, free, shared, buff/cache, and available memory
- Shows swap usage
Example output:
total used free shared buff/cache available
Mem: 62Gi 11Gi 20Gi 720Mi 31Gi 50Gi
Swap: 62Gi 228Ki 62Gi
What each field means:
- total: Total installed memory
- used: Memory currently in use
- free: Unused memory
- shared: Memory used by tmpfs
- buff/cache: Memory used for buffers and cache
- available: Memory available for new processes
- Swap: Disk space used as virtual memory
Show Human-Readable Format
free -h
What this does:
- Shows memory in human-readable units (KB, MB, GB, TB)
- Much easier to read
- Most commonly used free command
Example output:
total used free shared buff/cache available
Mem: 62Gi 11Gi 20Gi 720Mi 31Gi 50Gi
Swap: 62Gi 228Ki 62Gi
Show Memory in Megabytes
free -m
What this does:
- Shows memory in megabytes
- Useful for scripting
Show Continuous Updates
free -h -s 2
What this does:
- Updates every 2 seconds
- Useful for monitoring memory changes
- Exit with Ctrl+C
:desktop: TOP Commands
Start Top
top
What this does:
- Starts interactive process monitor
- Shows real-time system information
- Updates continuously
- Press
qto quit
What you'll see:
- System uptime and load average
- CPU usage breakdown
- Memory usage
- List of processes sorted by CPU usage
Top Output Explained
Header (top section):
top - 15:22:50 up 7:49, 4 users, load average: 2.64, 2.97, 2.03
Tasks: 566 total, 2 running, 563 sleeping, 0 stopped, 1 zombie
%Cpu(s): 4.0 us, 1.6 sy, 0.0 ni, 94.0 id, 0.0 wa, 0.4 hi, 0.0 si, 0.0 st
MiB Mem : 63842.0 total, 20903.7 free, 11643.7 used, 32729.5 buff/cache
MiB Swap: 63842.0 total, 63841.8 free, 0.2 used. 52198.4 avail Mem
What it shows:
- Load average: System load (1min, 5min, 15min)
- Tasks: Process counts (total, running, sleeping, stopped, zombie)
- CPU: CPU usage breakdown
us- User spacesy- System (kernel)ni- Nice (low priority)id- Idlewa- Wait I/Ohi- Hardware interruptssi- Software interruptsst- Steal time (virtualization)
Process list:
- PID: Process ID
- USER: Process owner
- PR: Priority
- NI: Nice value
- VIRT: Virtual memory
- RES: Resident memory (physical)
- SHR: Shared memory
- S: Status (R=Running, S=Sleeping, Z=Zombie)
- %CPU: CPU usage percentage
- %MEM: Memory usage percentage
- TIME+: CPU time used
- COMMAND: Command name
Top Interactive Commands
While top is running, press these keys:
q- Quith- Helpk- Kill process (enter PID)r- Renice process (change priority)f- Fields (choose what to display)o- Order by (change sort field)P- Sort by CPU usageM- Sort by memory usageT- Sort by timeu- Filter by user1- Show all CPUsW- Save configuration
Run Top in Batch Mode
top -b -n 1
What this does:
- Runs top once and exits (batch mode)
- Useful for scripting
-n 1means run once
Show Specific Number of Processes
top -n 20
What this does:
- Shows top 20 processes
- Useful for quick overview
:bulb: Common Troubleshooting
Check Memory Usage
free -h
Quick memory overview.
Find High CPU Processes
top
Then press P to sort by CPU usage.
Find High Memory Processes
top
Then press M to sort by memory usage.
Monitor Memory Continuously
watch -n 1 free -h
Updates every second.
Check System Load
top
Look at load average in header.
Load average interpretation:
- For single-core CPU: 1.0 = 100% utilization
- For 4-core CPU: 4.0 = 100% utilization
- Above 1.0 per core = system is overloaded
:link: Alternative: htop
If htop is installed:
htop
What this does:
- More user-friendly version of top
- Color-coded display
- Easier navigation
- Better visual representation
Install htop:
- Fedora:
sudo dnf install htop - Arch:
sudo pacman -S htop - Debian:
sudo apt install htop
:keyboard: Quick Reference
Free Commands
free # Memory usage (KB)
free -h # Human-readable
free -m # Megabytes
free -h -s 2 # Update every 2 seconds
Top Commands
top # Interactive monitor
top -b -n 1 # Batch mode (one run)
top -u username # Filter by user
Top Interactive Keys
q - Quit
P - Sort by CPU
M - Sort by memory
k - Kill process
h - Help
Summary
This guide covered:
- Free:
- Memory usage display
- Human-readable format
- Continuous monitoring
- Top:
- Interactive process monitor
- CPU and memory monitoring
- Process management
- Sorting and filtering
- Troubleshooting:
- Finding resource hogs
- Monitoring system load
- Memory usage checks
Next Steps:
- Practice with
free -hfor quick memory checks - Use
topto monitor system in real-time - Install
htopfor better experience - Combine with
psfor detailed process information
For process management, see the PS Process Management Guide. For system services, see the Systemctl Troubleshooting Guide.