How to Monitor CPU, RAM, Disk, and Network Usage on a Linux VPS
Monitoring your Linux VPS is essential for maintaining reliable application performance, identifying resource bottlenecks, and preventing unexpected service interruptions.
High CPU usage, insufficient RAM, full disks, excessive disk I/O, and network problems can affect website loading times, database performance, and overall server responsiveness.
In this guide, you will learn how to monitor CPU, RAM, disk space, disk I/O, and network usage on a Linux VPS using built-in Linux commands and commonly available monitoring utilities.
The instructions apply to Ubuntu, Debian, AlmaLinux, Rocky Linux, and other modern Linux distributions. Some utilities may require installation.
Prerequisites
- A Linux VPS with SSH access.
- A user account with sudo privileges.
- Basic familiarity with the Linux command line.
- Access to your server's package manager.
Looking for a Linux server? Explore Owned Networks KVM VPS hosting for full root access and flexible server resources.
1. Check Linux Server Uptime and Load Average
The uptime command provides a quick overview of server uptime and system load.
uptime
Example output:
10:30:15 up 12 days, 4:25, 2 users, load average: 0.45, 0.62, 0.58
The three load average values represent system load over approximately:
- 1 minute.
- 5 minutes.
- 15 minutes.
Linux load average includes tasks that are runnable or waiting in uninterruptible sleep, commonly associated with I/O operations.
For a CPU-bound workload, comparing load average with available CPU cores can help identify potential contention.
Check the number of logical CPU cores:
nproc
For example, a sustained load average of 8 on a VPS with 2 vCPUs may indicate significant CPU or I/O pressure.
Important: Load average is not a direct CPU utilization percentage. High load does not always mean the CPU is fully utilized.
2. Monitor CPU Usage with top
The top command displays running processes and real-time system resource utilization.
top
It provides information about:
- CPU utilization.
- Memory consumption.
- Running processes.
- Process IDs.
- System load.
- Process states.
Important CPU statistics include:
us— CPU time spent executing user-space processes.sy— CPU time spent executing kernel operations.id— CPU idle time.wa— CPU idle time while outstanding I/O requests exist.st— CPU time unavailable to a virtual machine because the hypervisor scheduled other work.
On virtualized infrastructure, sustained high CPU steal time may indicate host-level CPU contention.
Press q to exit top.
3. Install and Use htop
htop provides an interactive interface for monitoring processes, CPU usage, and memory consumption.
On Ubuntu or Debian:
sudo apt update
sudo apt install -y htop
On AlmaLinux or Rocky Linux:
sudo dnf install -y epel-release
sudo dnf install -y htop
Package availability depends on your distribution and enabled repositories.
Launch htop:
htop
Useful features include:
- Per-core CPU utilization.
- Memory and swap usage.
- Process sorting.
- Interactive process filtering.
- Process tree visualization.
Common keyboard shortcuts:
F3— Search for a process.F4— Filter processes.F5— Display process tree.F6— Select sorting criteria.F10— Exit.
4. Identify Processes Using the Most CPU
To display processes consuming the most CPU:
ps aux --sort=-%cpu | head -n 15
This command lists processes sorted by their reported CPU utilization.
To inspect a specific process:
ps -p PID -o pid,ppid,user,%cpu,%mem,etime,cmd
Replace PID with the actual process ID.
Important: The CPU percentage reported by ps is not necessarily an instantaneous measurement. Use top, htop, or other sampling tools when investigating current CPU spikes.
5. Monitor RAM Usage with free
The free command displays system memory and swap utilization.
free -h
Example output:
total used free shared buff/cache available
Mem: 3.8Gi 1.4Gi 420Mi 110Mi 2.0Gi 2.1Gi
Swap: 1.0Gi 120Mi 904Mi
Important values include:
- Total: Total available physical memory.
- Used: Memory currently classified as used.
- Free: Completely unused memory.
- Buff/cache: Memory used for buffers and filesystem caching.
- Available: Estimated memory available for starting applications without swapping.
Important: Low free memory is not automatically a problem. Linux uses otherwise unused RAM for filesystem caching.
The available value is generally more useful than free when evaluating memory pressure.
6. Identify Processes Consuming the Most RAM
Display the processes consuming the most memory:
ps aux --sort=-%mem | head -n 15
For a more detailed process view:
top -o %MEM
Common memory-intensive services include:
- Database servers.
- Java applications.
- PHP-FPM workers.
- Web application processes.
- Containerized applications.
If your VPS frequently runs out of memory, investigate application configuration, concurrent workloads, and memory leaks before increasing RAM.
7. Monitor Memory Pressure with vmstat
The vmstat command provides information about processes, memory, swapping, I/O, and CPU activity.
vmstat 1 10
This collects ten samples at one-second intervals. The first report may represent averages since system startup.
Important fields include:
r— Runnable tasks waiting for CPU execution.b— Tasks blocked in uninterruptible sleep.si— Swap data read into memory.so— Swap data written from memory.wa— CPU idle time while I/O operations are outstanding.
Sustained swapping activity may indicate memory pressure, although swap usage alone does not necessarily indicate a problem.
8. Check Disk Space Usage
Use df to inspect filesystem capacity:
df -h
Example output:
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 80G 42G 34G 56% /
tmpfs 2.0G 0 2.0G 0% /dev/shm
To inspect the root filesystem:
df -h /
To check inode usage:
df -i
A filesystem can run out of available inodes even when free disk space remains.
This commonly occurs when an application creates very large numbers of small files.
9. Find Directories Using the Most Disk Space
The du command helps identify directories consuming storage.
Inspect the largest directories under /var:
sudo du -xhd1 /var | sort -h
Inspect the root filesystem:
sudo du -xhd1 / | sort -h
The -x option prevents traversal into other mounted filesystems.
Common directories that may grow significantly include:
/var/log— System and application logs./var/lib/docker— Docker images, containers, and volumes./var/lib/mysql— MariaDB or MySQL database files./var/lib/postgresql— PostgreSQL database files./var/www— Website and application files./home— User files.
Warning: Do not manually delete database files, Docker storage directories, or unknown system files to recover disk space.
10. Monitor Disk I/O Performance with iostat
Disk performance can significantly affect database queries, application response times, and system responsiveness.
The iostat utility is included in the sysstat package.
On Ubuntu or Debian:
sudo apt install -y sysstat
On AlmaLinux or Rocky Linux:
sudo dnf install -y sysstat
Monitor disk I/O:
iostat -xz 1 5
Important metrics include:
r/s— Read operations per second.w/s— Write operations per second.rMB/s— Read throughput, when displayed.wMB/s— Write throughput, when displayed.await— Average I/O request time, including queueing and service time.%util— Percentage of time the device had I/O requests in progress, with interpretation depending on device architecture.
Field names and units can vary between sysstat versions.
Important: High %util alone does not prove that a modern SSD or virtual block device is saturated. Evaluate latency, throughput, queueing, and workload behavior together.
11. Identify Processes Generating Disk I/O
The iotop utility helps identify processes performing disk reads and writes.
On Ubuntu or Debian:
sudo apt install -y iotop
On AlmaLinux or Rocky Linux:
sudo dnf install -y iotop
Launch:
sudo iotop
To display processes currently performing I/O:
sudo iotop -o
Some virtualized environments may not expose all kernel accounting features required by certain versions of iotop.
If the utility is unavailable, use iostat, process statistics, and application logs to investigate disk activity.
12. Monitor Network Interfaces
Display available network interfaces:
ip -br addr
Display network interface statistics:
ip -s link
These commands help identify:
- Active network interfaces.
- Assigned IP addresses.
- Received and transmitted traffic counters.
- Packet errors.
- Dropped packets.
Network interface names vary between VPS environments and may include eth0, ens3, or other predictable interface names.
13. Monitor Network Bandwidth with vnStat
vnStat monitors network traffic using interface statistics and maintains historical usage records.
On Ubuntu or Debian:
sudo apt install -y vnstat
On AlmaLinux or Rocky Linux, install the package from an available repository if supported.
Enable the service:
sudo systemctl enable --now vnstat
Display network traffic statistics:
vnstat
Display daily usage:
vnstat -d
Display monthly usage:
vnstat -m
Display live traffic estimates:
vnstat -l
Note: Historical statistics require time to accumulate after installation. They do not automatically include traffic recorded before vnStat was installed.
14. Check Open Ports and Network Connections
The ss command displays socket and connection information.
List listening TCP and UDP sockets:
sudo ss -tulnp
Display established TCP connections:
ss -tn state established
Check connections associated with port 443:
sudo ss -tn '( sport = :443 or dport = :443 )'
These commands are useful when investigating:
- Unexpected listening services.
- Application connectivity problems.
- Large numbers of active connections.
- Network troubleshooting.
A high number of connections does not automatically indicate an attack. Interpret connection counts alongside application behavior, traffic patterns, and logs.
15. Monitor System Logs with journalctl
System logs can reveal service failures, resource problems, and authentication errors.
View recent system logs:
sudo journalctl -n 100 --no-pager
View logs from the current boot:
sudo journalctl -b --no-pager
Follow new log messages:
sudo journalctl -f
View SSH service logs on Ubuntu or Debian:
sudo journalctl -u ssh -n 100 --no-pager
On some RPM-based distributions, the OpenSSH service is named sshd:
sudo journalctl -u sshd -n 100 --no-pager
To inspect kernel messages:
sudo journalctl -k -n 100 --no-pager
16. Detect Out-of-Memory Events
When Linux experiences severe memory pressure, the kernel may terminate processes through the Out-of-Memory (OOM) killer.
Search kernel logs for possible OOM events:
sudo journalctl -k --no-pager | grep -Ei 'out of memory|oom-killer|killed process'
If you find OOM events, investigate:
- Memory consumption by applications.
- Concurrent process counts.
- Database memory configuration.
- PHP-FPM worker limits.
- Container memory limits.
- Available RAM and swap.
Repeated OOM events may indicate that applications require optimization or additional memory.
17. Monitor Docker Container Resource Usage
If Docker is installed, you can monitor resource consumption for running containers.
docker stats
This displays live statistics including:
- CPU utilization.
- Memory usage.
- Network I/O.
- Block I/O.
- Process counts.
For a single snapshot:
docker stats --no-stream
To inspect a specific container:
docker stats CONTAINER_NAME
Replace CONTAINER_NAME with the actual container name or ID.
18. Troubleshoot High CPU Usage
If your VPS becomes slow and CPU utilization remains high:
- Check system load using
uptime. - Inspect processes using
toporhtop. - Identify CPU-intensive applications.
- Review application and service logs.
- Investigate inefficient queries, background jobs, or excessive concurrency.
- Check CPU steal time in virtualized environments.
Useful commands:
uptime
top
ps aux --sort=-%cpu | head -n 15
vmstat 1 10
A temporary CPU spike may be normal. Sustained high utilization combined with application latency requires further investigation.
19. Troubleshoot High Memory Usage
When available RAM becomes low:
- Check available memory with
free -h. - Identify memory-intensive processes.
- Check swap activity with
vmstat. - Search for OOM events.
- Review application memory settings.
- Consider increasing VPS RAM if optimization is insufficient.
Useful commands:
free -h
ps aux --sort=-%mem | head -n 15
vmstat 1 10
20. Troubleshoot High Disk Usage
If your VPS reports insufficient disk space:
- Check filesystem usage with
df -h. - Check inode usage with
df -i. - Identify large directories using
du. - Review application logs and backup retention.
- Investigate unused files using application-supported cleanup procedures.
- Expand storage if necessary.
Useful commands:
df -h
df -i
sudo du -xhd1 /var | sort -h
sudo journalctl --disk-usage
Warning: Never delete unknown files from database directories, container storage, or system paths without understanding their purpose.
21. Linux VPS Monitoring Best Practices
- Monitor CPU, memory, disk, and network resources regularly.
- Investigate sustained resource usage rather than isolated spikes.
- Maintain sufficient free disk space and available memory.
- Review system and application logs.
- Monitor disk latency as well as disk capacity.
- Track network traffic trends.
- Configure alerts for critical resource thresholds.
- Review resource usage after application deployments.
- Keep operating systems and applications updated.
- Maintain reliable backups before performing major maintenance.
For production workloads, consider deploying a monitoring platform capable of collecting historical metrics and generating alerts.
Examples include Prometheus, Grafana, Zabbix, and Netdata.
Related Linux VPS Tutorials
- How to Set Up and Secure a New Ubuntu VPS
- How to Configure UFW Firewall on an Ubuntu VPS
- How to Install and Configure Fail2ban on an Ubuntu VPS
- How to Set Up Automatic Backups on an Ubuntu VPS Using Restic
- How to Install Docker and Docker Compose on Ubuntu
Monitor and Optimize Your VPS with Owned Networks
Deploy websites, applications, databases, and development environments on an Owned Networks KVM VPS with full root access and flexible server resources.
Understanding CPU, memory, storage, and network utilization helps you identify performance bottlenecks, optimize applications, and plan infrastructure upgrades.
Explore Owned Networks VPS Hosting and deploy your next Linux server today.