To monitor RAM usage on a Linux-based VPS, you can use several terminal commands depending on the level of detail you need. Below is a clear overview of the most commonly used commands and what each one is used for.
Check Overall RAM Usage (Recommended)
The free command is the easiest and most commonly used way to check RAM usage.
free -h
What it shows:
- Total installed RAM
- Used memory
- Free memory
- Cached and buffered memory
- Available memory
The -h option formats the output in a human-readable format (MB/GB).
Best choice for a quick overview of RAM usage
View Detailed RAM Information
To see detailed, system-level memory information, use:
cat /proc/meminfo
What it shows:
- Total RAM
- Free RAM
- Buffered memory
- Cached memory
- Swap memory details
This command is useful for advanced troubleshooting and in-depth analysis.
View Memory Statistics Summary
The vmstat command provides summarized virtual memory statistics.
vmstat -s
What it shows:
- Total memory
- Used and free memory
- Swap usage
- Memory paging statistics
Useful for understanding overall memory behaviour.
Monitor Memory Usage by Processes (Real-Time)
To see which processes are using the most RAM in real time, use:
top
What it shows:
- Running processes
- RAM usage per process
- CPU usage
- System load
Useful for identifying memory‑heavy processes.
Advanced Real-Time Monitoring (Recommended)htop is an improved version of top with a more user-friendly interface.
htop
What it shows:
- RAM and CPU usage with visual bars
- Processes sorted by memory or CPU usage
- Easier process management and filtering
Recommended for regular monitoring and troubleshooting