You can use the following commands on CentOS to find memory usage info:
- free command
- top or htop command
- vmstat command
- dmidecode command
- /proc/meminfo file
Centos memory usage free command
You need to use the free command to see total amount of free and used physical and swap memory in the server, as well as the buffers used by the CentOS Linux kernel. The basic syntax is as follows:
# free
# free [options]
# free -m
# free -k
# free -t
# free -l
# free -o
# free -s 2
# free -g
Sample outputs showing total 12GB ram from my server:
total used free shared buffers cached Mem: 11 11 0 0 0 8 -/+ buffers/cache: 2 9 Swap: 5 0 5
The free command line options are as follows:
-b,-k,-m,-g show output in bytes, KB, MB, or GB -l show detailed low and high memory statistics -o use old format (no -/+buffers/cache line) -t display total for RAM + swap -s update every [delay] seconds -c update [count] times -V display version information and exit
A better tool is top or htop command (see how to install htop command on RHEL/CentOS):
# top
OR
# htop
Sample outputs:
You can grab the same info from /proc/meminfo file using the following cat command:
$ cat /proc/meminfo
vmstat command
Type the vmstat command as follows:
# vmstat
# vmstat -s
Sample outputs:
12195116 total memory 12015316 used memory 5579508 active memory 5588540 inactive memory 179800 free memory 375484 buffer memory 9316920 swap cache 6291448 total swap 123148 used swap 6168300 free swap 9153213 non-nice user cpu ticks 2353 nice user cpu ticks 3327358 system cpu ticks 829062384 idle cpu ticks 325448 IO-wait cpu ticks 9047 IRQ cpu ticks 1070159 softirq cpu ticks 0 stolen cpu ticks 4993388 pages paged in 1012906825 pages paged out 28376 pages swapped in 53969 pages swapped out 2338886238 interrupts 1688714597 CPU context switches 1387092323 boot time 245692 forks
Related media
This tutorial is also available in a quick video format:
Video 01: 5 Linux Commands: To See Amount Of Free and Used Memory
CentOS Linux see installed ram size and other memory info
Use the dmidecode command for dumping a computer’s DMI (some say SMBIOS) table contents in a human-readable format. This table contains a description of the system’s hardware components, as well as other useful pieces of information such as serial numbers and BIOS revision:
# dmidecode --type memory