How do I check used and free RAM memory usage under Linux operating systems using command line and GUI tools?
Linux comes with different set of commands to check memory usage. The free command 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 vmstat command reports information about processes, memory, paging, block IO, traps, and cpu activity. Finally, you can use the top, and/or atop/htop commands which provides a dynamic real-time view of a running system. top and friends can display system summary information as well as a list of tasks currently being managed by the Linux kernel.
|Estimated completion time||N/A|
The /proc/meminfo file stores statistics about memory usage on the Linux based system. The same file is used by free and other utilities to report the amount of free and used memory (both physical and swap) on the system as well as the shared memory and buffers used by the kernel.
MemTotal: 8120568 kB MemFree: 2298932 kB Cached: 1907240 kB SwapCached: 0 kB SwapTotal: 15859708 kB SwapFree: 15859708 kB
To display free memory size in MB (megabytes):
$ free -m
total used free shared buffers cached Mem: 750 625 125 0 35 335 -/+ buffers/cache: 254 496 Swap: 956 0 956
Displays a line containing the totals memory in MB:
$ free -t -m
total used free shared buffers cached Mem: 750 625 125 0 35 335 -/+ buffers/cache: 253 496 Swap: 956 0 956 Total: 1707 625 1082
So how much free ram I have?
Type the following command:
$ free -m
In this above output, my server has used 2825 MB ram, and 9083 MB is available for other users and programs.
A list of free command 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
Type the vmstat command at shell prompt:
procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu---- r b swpd free buff cache si so bi bo in cs us sy id wa 1 0 0 131620 35432 341496 0 0 42 82 737 1364 15 3 81 1
Type top command at the shell prompt:
To exit from top command type q key.
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. It is similar to top command but comes with additional advanced options. By default, the atop command is not installed on most Linux distributions.
The program htop is an interactive process viewer. It is similar to top, but allows to scroll the list vertically and horizontally to see all processes and their full command lines.
By default, the htop command is not installed on most Linux distributions.
GNOME Desktop: GUI tool to see memory usage
The "Gnome System Monitor" application enables you to display basic system information and monitor system processes, usage of system resources, and file systems. You can also use System Monitor to modify the behavior of your system. You can start System Monitor by visiting System menu > Choose Administration > System Monitor option. Or type the following command at the shell prompt:
Check out related media
(Video 01: Top five commands to see used and free memory under Linux)
A note about the performance
- RAM - An occupation percentage of 90% is considered as critical.
- SWAP - An occupation percentage of 80% is considered as critical.
- To solve performance related problems, add more RAM and increase the swap space (or move swap space to another disk controller).
Read man pages of free, vmstat, top, atop, and htop commands for more information.TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!
- 30 Cool Open Source Software I Discovered in 2013
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012
- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop