Sometimes, when you are working on a Linux environment, you may need to install some new packages on a daily basis. For this purpose, you need to check memory usage to install a new program. So, you should know how to check available and installed RAM or memory on your system.
In this article, we will explore some major commands that are useful to check the memory usage in CentOS 8.
You should have root account or sudo privileges to run the administrative commands.
You can check the memory usage on your CentOS 8 Linux system by using the following five different commands which we will explain one by one in detail:
- Cat command
- Free command
- Vmstat command
- Top command
- Htop command
Use of cat command
Open the terminal and type cat /proc/meminfo on the terminal window. It will open the /proc/meminfo virtual file that displays the information about used and available memory.
It displays the real-time information about the memory usage as well as the shared memory which is used by the kernel, buffers details.
Use of free command
When you will execute the free command on the terminal, it will display the following information:
The above-displayed image contains different terms that we will explain one by one as follows:
Data represented in the above image, such as under the used, available, and swap memory terms are in kilobytes.
total represents the total memory installed on your system
used how much memory is currently using by running tasks ( you can calculate used memory = total – free – buffer/cache)
free represents the memory that is not being used
shared shows the amount of memory that is being shared by different multiple processes
Buffers amount of memory which is reserved by the OS kernel. This memory is further allocated as buffers when process will need
cached how much memory is used to store recently files in RAM
buff/cache Buffers + Cache memory
Available shows memory which is available for starting new tasks, without swapping.
Using the following command you can explore a complete description and all options of free command:
$ man free
Use of vmstat Command
The vmstat command is used to display complete statistics of virtual memory.
This command gives the information about the memory, system processes, CPU activity, paging, block IO, and traps.
Use of top command
Top command is a very useful command line tool that is used to examine the memory and CPU usage per process. It displays the information about the following things:
- average load
- tasks running
- Information about the of users logged in
- number of CPU utilization
- Swap and memory/ system processes
Using the above top command, data is updated in a continuous manner, which allows you to monitor the memory for the processes in a real-time.
Use of htop command
The htop command provides similar information like the top command. However, one of the main advantages of the htop command is that it offers a user-friendly environment and improved control options.
For interactive interface, the htop command uses colors for displaying its output, gives a full command line environment for all processes, as well as it has the option to scroll the page both horizontally and vertically. Press Ctrl+c to exit from the current window.
You will see the following screen on your terminal:
- The top section provides the information summary and contains graphic text counters.
- The middle section displays the detailed data of per process. It allows you to easily perform the separate actions on every individual process.
- All shortcuts are listed at the bottom of the displaying window that will enable you to customize and manipulate the processes quickly without using any command.
If this utility is not installed on your CentOS 8 system then, using the following command you can install it on your system:
$ sudo yum install htop
Check Memory using GUI
If you want to check memory using the graphical user interface then, using the following method you can easily perform this action:
Type ‘system monitor’ in the application search bar.
Click on the above displaying icon. The following window will open on your system.
Select the ‘Resources’ tab where you can easily monitor the memory usage.
Today, we have learned in this article how to check the memory usage on the CentOS 8 system. Moreover, we have executed different commands such as cat, free, vmstat, top and htop that are used to display the memory information. Using these commands, you can easily get information about your system RAM, and CPU. Thanks for reading the above article.
Samreena Aslam holds a master’s degree in Software Engineering. She’s a technical writer and has written various articles on different Linux flavours including Ubuntu, Debian, CentOS and Mint.