Introduction
In this article we will see basic commands to check the physical memory on the server under Linux. Many beginners struggle to know their system well in the context of resources such as CPU, Memory, Disks, etc. So I decided to write this small item pointing command to check the RAM on the Linux server. These commands will work in different flavors of Linux like Red Hat, CentOS, Suse, Ubuntu, Fedora, Debian etc.
1) Using free command
This command is mainly used to check the RAM and SWAP on the system. Using a different change, you can change the output byte format. Like -b for bytes, -k for kilobytes, -m for megabytes, and -g for gigabytes.
# free -b
total used free shared buff/cache available
Mem: 3976634368 3096838144 187990016 51572736 691806208 540106752
Swap: 4001361920 8826880 3992535040
# free -k
total used free shared buff/cache available
Mem: 3883432 3024204 183600 50364 675628 527488
Swap: 3907580 8620 3898960
# free -m
total used free shared buff/cache available
Mem: 3792 2953 179 49 659 515
Swap: 3815 8 3807
# free -g
total used free shared buff/cache available
Mem: 3 2 0 0 0 0
Swap: 3 0 3
2) Using /proc/meminfo file
# cat /proc/meminfo |grep Mem MemTotal: 3883432 kB MemFree: 183268 kB MemAvailable: 527276 kB
3) Using top command
# top top - 12:36:36 up 8 days, 2:58, 2 users, load average: 0.14, 0.14, 0.08 Tasks: 213 total, 1 running, 212 sleeping, 0 stopped, 0 zombie %Cpu(s): 0.2 us, 0.7 sy, 0.0 ni, 99.0 id, 0.2 wa, 0.0 hi, 0.0 si, 0.0 st KiB Mem : 3883432 total, 182356 free, 3025080 used, 675996 buff/cache KiB Swap: 3907580 total, 3898960 free, 8620 used. 526608 avail Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 2303 root 20 0 2378464 541076 7692 S 1.0 13.9 417:16.56 OpsCenterDBd
4) Using vmstat
[root@opscenter ~]# vmstat -s
3883432 K total memory
3025552 K used memory
2439780 K active memory
870348 K inactive memory
181812 K free memory
138712 K buffer memory
537356 K swap cache
3907580 K total swap
8620 K used swap
3898960 K free swap
2323674 non-nice user cpu ticks
2978 nice user cpu ticks
944914 system cpu ticks
135133743 idle cpu ticks
692582 IO-wait cpu ticks
121 IRQ cpu ticks
49623 softirq cpu ticks
0 stolen cpu ticks
1931906 pages paged in
23034525 pages paged out
377 pages swapped in
2353 pages swapped out
956323695 interrupts
2040196891 CPU context switches
1505191059 boot time
849343 forks
