RAM is the abbreviation of “Random Access Memory” that stores data temporarily while a computer is running. In Linux, the amount of available RAM can affect the system performance and running applications on it.
This article will demonstrate various methods to check out the RAM on Linux. The supported content that illustrates this guideline is as follows:
- Use the “free” Command
- Use the “top” Command
- Using /proc/meminfo File
- Using htop Command
- Using vmstat Command
Let’s start the article with the first method.
Method 1: Use the “free” Command
The “free” command shows the used and free memory in the system, along with the swap space usage. To display the information in a more human-readable format, you can use the -h option, which shows the values in “human-readable” format (e.g., in MB or GB):
$ free -h
The output returns the total memory used, free, shared, buff/cache, and available.
Method 2: Use the “top” Command
The “top” command is a system monitoring utility that displays information about the running processes, including the amount of memory used. To see the memory usage, press the “m” key. The output will show the total amount of physical memory and the amount of used and free memory:
The output has a row that contains the total, use, free, and bugg/cache in MBs. Additionally, the memory of running processes is displayed in percentage.
Method 3: Using /proc/meminfo File
The “/proc/meminfo” file contains the system’s memory usage. You can use the “cat” command to display the contents of this file:
$ cat /proc/meminfo
This is more detailed information from where you can see the memory information in KBs.
Method 4: Using htop Command
The htop command is the aesthetic version of the top command where you see the colorful output. This utility is not installed on Linux by default, but you can install using the commands:
$ sudo apt install htop #Debian/Ubuntu based $ sudo yum install htop # CentOS $ sudo snap install htop # Fedora
After installation of the “htop” utility, check the utilization of RAM in the system by executing the below script:
The output returns the overall usage of RAM “950MB” out of “1.90GB” and memory consumption of each running process in percentage.
Method 5: Using vmstat Command
To extract the information about memory, the vmstat command is utilized. It displays the total, used, active, inactive, free, buffer, swap cache, and bugg/cache in KB’s format.
$ vmstat -s
The output shows the detailed information of memory in enlisted format.
These are methods to check RAM in Linux.
In Linux, the “free”, “top”, “htop” and “vmstat” commands are used to check the utilization of RAM in the system. Additionally, the “/proc/meminfo” file contains the complete information of RAM including total memory, used, free, buff/cache, etc. These above methods update the statistics and display the RAM usage in the system. This article has provided several ways for checking the RAM on Linux.