0
0
Linux CLIscripting~10 mins

System resource monitoring (free, uptime, vmstat) in Linux CLI - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - System resource monitoring (free, uptime, vmstat)
Run 'free' command
Display memory usage
Run 'uptime' command
Show system uptime and load
Run 'vmstat' command
Show CPU, memory, IO stats
End of monitoring snapshot
The flow shows running three commands one after another to get memory, uptime, and system stats snapshots.
Execution Sample
Linux CLI
free
uptime
vmstat 1 2
Runs free to show memory, uptime for system time/load, vmstat for CPU/memory stats twice with 1 second interval.
Execution Table
StepCommandOutput SummaryDetails
1freeShows total, used, free memory and swapMem: total=8000MB, used=3000MB, free=5000MB; Swap: total=2000MB, used=0MB, free=2000MB
2uptimeShows system uptime and load averagesUptime=5 days 3:20, Load averages=0.15, 0.10, 0.05
3vmstat 1 2 (first)First vmstat snapshotr=1, b=0, swpd=0, free=5000, buff=200, cache=1000, si=0, so=0, bi=10, bo=5, in=100, cs=200, us=5, sy=3, id=90, wa=2, st=0
4vmstat 1 2 (second)Second vmstat snapshot after 1 secondr=0, b=0, swpd=0, free=4800, buff=250, cache=1100, si=0, so=0, bi=5, bo=3, in=90, cs=180, us=3, sy=2, id=95, wa=0, st=0
5EndMonitoring snapshot completeAll commands executed, system stats captured
💡 All commands completed, system resource snapshot taken
Variable Tracker
VariableStartAfter freeAfter uptimeAfter vmstat 1After vmstat 2Final
Memory Used (MB)unknown30003000300030003000
Memory Free (MB)unknown50005000500048004800
System Uptimeunknownunknown5 days 3:205 days 3:205 days 3:205 days 3:20
CPU Usage User (%)unknownunknownunknown533
CPU Idle (%)unknownunknownunknown909595
Key Moments - 3 Insights
Why does vmstat show two sets of data when we run 'vmstat 1 2'?
The first vmstat output shows stats since last reboot, the second is the real snapshot after 1 second interval (see rows 3 and 4 in execution_table).
What does the 'load average' in uptime mean?
Load average shows average system demand over 1, 5, and 15 minutes, indicating how busy the CPU is (see row 2 in execution_table).
Why is free memory different between free and vmstat outputs?
free shows memory including buffers/cache, vmstat separates free memory and buffers/cache (see variable_tracker Memory Free values).
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table row 2, what is the system uptime shown by 'uptime'?
A5 hours 3 minutes
B5 days 3:20
C3 days 5:20
DUnknown
💡 Hint
Check the 'Output Summary' and 'Details' columns in execution_table row 2.
At which vmstat snapshot does CPU idle percentage increase?
ASecond snapshot
BFirst snapshot
CBoth snapshots are equal
DCPU idle is not shown
💡 Hint
Compare 'CPU Idle (%)' in variable_tracker after vmstat 1 and vmstat 2.
If the system had more swap used, which command output would show it clearly?
Avmstat
Buptime
Cfree
DNone of these
💡 Hint
Look at the 'free' command output in execution_table row 1 showing swap usage.
Concept Snapshot
System resource monitoring uses commands:
- free: shows memory and swap usage
- uptime: shows system running time and load averages
- vmstat: shows CPU, memory, IO stats in intervals
Run them sequentially for a snapshot of system health.
Full Transcript
This visual execution shows how to monitor system resources on Linux using three commands: free, uptime, and vmstat. First, 'free' displays memory and swap usage, telling how much RAM is used and free. Next, 'uptime' shows how long the system has been running and the load averages, which indicate CPU demand. Finally, 'vmstat' gives detailed CPU, memory, and IO statistics, showing two snapshots with a 1-second gap. The execution table traces each command's output step-by-step, and the variable tracker follows key values like memory used, free memory, uptime, and CPU usage. Key moments clarify common confusions like why vmstat shows two outputs and what load averages mean. The quiz tests understanding by asking about uptime, CPU idle changes, and swap usage visibility. This helps beginners see how these commands work together to give a clear picture of system health.