Linux operating system comes with many commands to check memory usage. The “free” command usually displays the total amount of free and used physical and swap memory in the system, as well as the buffers used by the kernel. The “top” command provides a dynamic real-time view of a running system.
The top command can display system summary information as well as a list of the process currently being managed by the Linux kernel.
In this article we will see the ways to check the memory usage on CentOS.
Checking memory usage on CentOS
Follow the below command to check memory usage on Linux machine.
/proc/meminfo
You can check memory usage is to read the /proc/meminfo file. The same file is used to know the free and other utilities report of free and used memory (both physical and swap) on the system.
# cat /proc/meminfo
or
# egrep --color 'Mem|Cache|Swap' /proc/meminfo
You will get some output like below:
MemTotal: 7996284 kB
MemFree: 5415608 kB
Cached: 92416 kB
SwapCached: 35924 kB
SwapTotal: 8187836 kB
SwapFree: 8059332 kB
free Command
You can check the total free and used physical and swap memory as well as the buffer used using free command.
# free -m
You will get some output like below:
total used free shared buffers cached
Mem: 1006 317 689 0 36 190
-/+ buffers/cache: 90 916
Swap: 2015 0 2015
where Command
The whereis command lets users locate binary, source, and manual page files for a command. Following is its syntax:
Whereis [options]
-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
vmstat command
vmstat reports information about processes, memory, paging, block IO, traps, and cpu activity.
# vmstat
You will some output like below:
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
0 0 0 701072 38236 198804 0 0 18 23 88 97 1 3 96 1 0
The vmstat command with the s option, lays out the memory usage statistics much like the proc command.
# vmstat -s
You will some output like below:
7996284 total memory
3028732 used memory
2587708 active memory
253600 inactive memory
4967552 free memory
32212 buffer memory
97732 swap cache
8187836 total swap
127572 used swap
8060264 free swap
2629730 non-nice user cpu ticks
890 nice user cpu ticks
335618 system cpu ticks
80671997 idle cpu ticks
14269700 IO-wait cpu ticks
8 IRQ cpu ticks
12963 softirq cpu ticks
0 stolen cpu ticks
320259348 pages paged in
496267028 pages paged out
40038 pages swapped in
85154 pages swapped out
151875583 interrupts
278983792 CPU context switches
1438090342 boot time
300883 forks
atop command
The program atop is an interactive monitor to view the load on a Linux system. This program can display the amount of used and free memory, i.e. cpu, memory, disk and network.
# atop
htop command
It is similar to top, also allows you to see all the processes running on the system, with their full command lines.
#htop
top command
The Linux top command is used to show all the running processes within your Linux environment.
#top
or
# top c
Hope, this article helps you. Please share your valuable feedback to improve us.