📖 Scenario: You are a system administrator who needs to check the health of a Linux server. You want to monitor memory usage, system uptime, and CPU activity using simple Linux commands.
🎯 Goal: Learn to use free, uptime, and vmstat commands to monitor system resources and understand their outputs.
📋 What You'll Learn
Use the free command to check memory usage
Use the uptime command to check how long the system has been running
Use the vmstat command to check CPU and memory statistics
💡 Why This Matters
🌍 Real World
System administrators regularly check server health to prevent crashes and performance issues by monitoring memory, uptime, and CPU usage.
💼 Career
Knowing these commands is essential for Linux system administrators, DevOps engineers, and anyone managing servers to ensure smooth operations.
Progress0 / 4 steps
1
Check Memory Usage with free
Run the free -m command to display memory usage in megabytes.
Linux CLI
Hint
The -m option shows memory in megabytes, which is easier to read.
2
Check System Uptime with uptime
Run the uptime command to see how long the system has been running and the load averages.
Linux CLI
Hint
The uptime command shows the current time, how long the system has been running, and load averages.
3
Monitor CPU and Memory with vmstat
Run the vmstat 1 2 command to display CPU and memory statistics twice with a 1-second interval.
Linux CLI
Hint
The vmstat 1 2 command shows system stats twice, one second apart, to observe changes.
4
Display All Monitoring Outputs
Run all three commands in sequence: free -m, uptime, and vmstat 1 2 to see memory, uptime, and CPU stats.
Linux CLI
Hint
Run all commands one after another to get a full picture of system resources.
Practice
(1/5)
1. What does the free command primarily display on a Linux system?
easy
A. System uptime and load average
B. Disk usage statistics
C. CPU temperature
D. Memory usage and availability
Solution
Step 1: Understand the purpose of free
The free command shows information about the system's memory usage, including total, used, free, and available memory.
Step 2: Compare with other commands
uptime shows system running time and load, vmstat shows detailed CPU and memory stats, but free focuses on memory.
"command not found" means vmstat (from procps package) is not installed.
Final Answer:
vmstat is not installed on the system -> Option A
Quick Check:
command not found = not installed [OK]
Hint: vmstat missing? Install procps package [OK]
Common Mistakes:
Assuming syntax error for missing command
Thinking root needed for vmstat
Believing interval too small
5. You want to monitor CPU and memory usage every 2 seconds for 5 samples using vmstat. Which command will correctly do this and what will be the total monitoring time?
hard
A. vmstat 2 5; total time 10 seconds
B. vmstat 5 2; total time 10 seconds
C. vmstat 2 5; total time 8 seconds
D. vmstat 5 2; total time 8 seconds
Solution
Step 1: Understand vmstat interval and count
vmstat 2 5 runs vmstat every 2 seconds, 5 times total.
Step 2: Calculate total monitoring time
vmstat prints the first line immediately, then 4 intervals of 2 seconds each, so total time = 2 * (5 - 1) = 8 seconds.
Final Answer:
vmstat 2 5; total time 8 seconds -> Option C
Quick Check:
Total time = interval * (count - 1) [OK]
Hint: Total time = interval x (count - 1) for vmstat [OK]
Common Mistakes:
Multiplying interval by count instead of count-1
Swapping interval and count values
Assuming total time equals interval x count
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.