Contents...
Linux 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 I will describe lots of way to check the memory usage on Linux.
Check Memory Usage on Linux
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;
-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
You will get some output like below:
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
You will some output like below:
top command
The Linux top command is used to show all the running processes within your Linux environment.
# top
You will some output like below:
Tasks: 84 total, 1 running, 83 sleeping, 0 stopped, 0 zombie Cpu(s): 0.5%us, 2.4%sy, 0.0%ni, 96.0%id, 0.8%wa, 0.0%hi, 0.2%si, 0.0%st Mem: 1030888k total, 324996k used, 705892k free, 37324k buffers Swap: 2064376k total, 0k used, 2064376k free, 194916k cached
If you find this tutorial helpful please share with your friends to keep it alive. For more helpful topic browse my website www.looklinux.com. To become an author at LookLinux Submit Article. Stay connected to Facebook.
Leave a Comment