How to check CPU, RAM, Disk parameters on Linux
The first job we need to do right after receiving the VPS / Server login account is to check if your CPU, RAM, and Disk configuration is correct.In this article, I will introduce some simple commands to check each server parameter.
1. Check CPU information
The nproc command to display the number of processor units in your computer, use the following:
You can simplify viewing your system CPU information by reading the /proc/cpuinfo file with the cat command.
$ cat /proc/cpuinfo
2. Check RAM information
Simple memory capacity check
The simplest way to check your VPS’s memory capacity is to use the free command
here I will execute the command free -h:
$ free -h
The results show that my VPS has the following RAM memory parameters:
- (1) Total memory capacity is 1.9 GB (total)
- (2) Used 68 MB (used)
- (3) Free space equal to 1.6 GB (free)
- (4) The amount of memory used for caching is 293 MB (buff/cache)
-The amount of free RAM is only 1.6 GB (free), but you can actually use more than that. Total usable memory will be equal to free + buff/cache. So here, the amount of RAM actually usable will be 1.893 GB
-The amount of RAM that is buffed/cached is often used to improve disk read and write performance. Because the RAM set will have a much higher query and read speed than the disk read and write speed, the operating system uses the available RAM to improve performance
Advanced memory capacity check
To check the detailed parameters of RAM, we will check the file /proc/meminfo. The free command itself also uses the meminfo file to check the amount of RAM memory of VPS.
The statistics in the /proc/meminfo file are quite a lot, so I will only focus on the important memory parameters
$ egrep --color 'Mem|Cache' /proc/meminfo
I will explain the results below
- (1) MemTotal: This is the total amount of RAM available (Unit kilobytes). Here the value is equal to 1882868 kB ie 1.8 GB as the result of the free statement
- (2) MemFree: This is the amount of free RAM memory, the value is equal to 1581892 kB or 1.5 GB
- (3) MemAvailable: This is the total amount of usable RAM, the value is equal to 1616352 kB or 1.6 GB. As I said, although the amount of free memory is 1.5 GB, you can use more.
- (4) Cached: This is the amount of memory used as cache. Because RAM memory will have a very high read and write query speed, the operating system uses the available RAM to improve performance, but when it needs to use RAM, the operating system will automatically release the cache memory.
The reason why the amount of RAM VPS received is lacking
At this point, I think some of you will wonder why I signed up for VPS package X with 2GB of RAM, but when I checked, the operating system only received 1.9 GB. So did the operating system receive lack of RAM or the provider provided insufficient memory for VPS?
Here I will explain why. In fact, the Linux operating system has received enough RAM capacity of 2 GB, but during the operating system boot process some of the RAM has been occupied by the system kernel (Kernel Linux).
I will check with the command:
$ dmesg | grep -i memory
- Looking at (1) we see that although the total capacity is 2 GB (2096616kB) but only 1.9 GB (1978844Kb) can be used.
- Notice (2), we will note the value 117772K reserved, the price shown during the boot process of the operating system kernel that used 117,772MB to execute some special modules.
If we add the value 117772K with the usable memory capacity of 1978844K, we will get a value close to or equal to the physical memory capacity of VPS. However, you do not have to worry because the amount of memory used for the operating system kernel will be partially freed, returned to RAM memory. So even though the memory capacity is 1.9 GB, you can use more than that.
3. Check hard drive information
The “df” command means “disk filesystem”, used to display a complete summary of the available and used hard disk space usage of the file system on Linux.
Check disk space
Display information of all used disk space
The command “df -a” will display information of the file systems along with all the disk space usage of the file system.
Show hard drive space usage
The default hard drive capacity information is in bytes, which is difficult to read. Command “df -ha”, prints the result in an easy to read format (K, M, G)
Display capacity information of /home/file system
$ df -hT /home
Display the capacity of File system in Byte
To display size information of all file systems in 1024-byte blocks, use the variable “-k”
Display the size of the File system in Megabytes
$ df -m
Show Inodes information of file system
$ df -i
Show file system types
To check the file system types in use, we use the variable “Th”
Display information based on file system type
To display some file system types use “-t” and add the name of the file type.
Display information of df command
The “-–help” command will list the options available to the “df” command
4. Check Operating System Information
Operating system information:
$ cat /etc/*-release
Check the parameters of the hard drive
$ dd if=/dev/zero of=1GB.tmp bs=1024 count=1M conv=fdatasync
You can see the hard drive speed on vps is 175 MB/s (SSD Disk)