0
0
Linux CLIscripting~5 mins

System resource monitoring (free, uptime, vmstat) in Linux CLI - Commands & Configuration

Choose your learning style9 modes available
Introduction
Sometimes your computer or server feels slow or unresponsive. To understand why, you need to check how much memory, CPU, and uptime it has. The commands free, uptime, and vmstat help you see this information quickly.
When your server is running slow and you want to check if it is out of memory.
When you want to know how long your system has been running without a restart.
When you want to see CPU usage and system activity in real time.
When you need to check if your system is swapping memory to disk, which slows it down.
When you want to monitor system performance before and after installing new software.
Commands
This command shows how much memory is free, used, and available on your system in a human-readable format.
Terminal
free -h
Expected OutputExpected
total used free shared buff/cache available Mem: 7.7G 2.1G 3.2G 150M 2.4G 5.0G Swap: 2.0G 0B 2.0G
-h - Shows memory sizes in human-readable format like MB or GB
This command tells you how long the system has been running, how many users are logged in, and the system load averages.
Terminal
uptime
Expected OutputExpected
14:35:22 up 3 days, 4:12, 2 users, load average: 0.15, 0.10, 0.05
This command shows system performance statistics like CPU, memory, and I/O every 1 second, 3 times in total.
Terminal
vmstat 1 3
Expected OutputExpected
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu----- r b swpd free buff cache si so bi bo in cs us sy id wa st 1 0 0 3300000 250000 1200000 0 0 5 10 100 200 5 2 90 3 0 0 0 0 3298000 250000 1201000 0 0 0 0 110 210 3 1 95 1 0 0 0 0 3297000 250000 1202000 0 0 0 0 105 205 4 1 94 1 0
1 - Interval in seconds between updates
3 - Number of updates to show
Key Concept

If you remember nothing else from this pattern, remember: free shows memory use, uptime shows system running time and load, and vmstat shows detailed system activity over time.

Common Mistakes
Running 'free' without the -h flag
The output shows memory in bytes, which is hard to read and understand quickly.
Always use 'free -h' to see memory sizes in MB or GB for easier reading.
Running 'vmstat' without interval and count arguments
It only shows a single snapshot, which may not represent ongoing system activity.
Use 'vmstat 1 3' or similar to see continuous updates and understand trends.
Confusing load average from 'uptime' with CPU usage percentage
Load average shows how many processes want CPU time, not the CPU usage percent, so it can be misunderstood.
Use load average as a sign of system demand, and vmstat or other tools for CPU usage details.
Summary
Use 'free -h' to check how much memory is free and used in a readable format.
Use 'uptime' to see how long the system has been running and current load averages.
Use 'vmstat 1 3' to monitor CPU, memory, and I/O activity over time with repeated updates.