1. free Command
free
command used to display the total amount of free and used memory, Buffers and caches used by the kernel and swap memory in the system. Use free command in terminal to see the free and used memory in Linux/Ubuntu.
** If you want to see memory usage in MB, use free-m
command in terminal.
** If you want to see memory usage in MB, use free-g
command in terminal.
** If you want to see memory usage and Total memory, use free-mt
command in terminal.
2. vmstat
vmstat
command used to display virtual memory statistics. vmstat command will display memory statistics about processes, memory, paging, block IO, traps, and CPU.
You can use vmstat command in two ways.
vmstat
Use vmstat
if you want to see memory statistics in default format.
vmstat -s
Use vmstat -s if you want to memory statistics in a single column. We recommend using vmstat-s command as its report is easier to understand.
3. top Command
top
command displays memory and CPU usage per process. It provides a dynamic, real-time view of a running system. You can also use top
command to find the Process ID (PID), You can use Process ID (PID) to kill or troubleshoot unwanted tasks.
**If you want to sort usage per process by memory used, use top -o %MEM
command in the terminal.
4. /proc/meminfo
You can also use /proc/meminfo
to check RAM memory usage. Use less
or cat
command along with /proc/meminfo
to view RAM usage. Using this command, you can see the MemTotal, MemFree, Buffers, Cached, SwapTotal, SwapFree.
** It shows the same values of memory usage as the free
command.
** The data of /proc/meminfo
file can be parsed and used in shell scripts.
cat /proc/meminfo
less /proc/meminfo
5. dmidecode Command
Use dmidecode
command to see the information about the installed RAM memory. Use sudo dmidecode -t 17
command in terminal to see the information about the installed RAM memory.
sudo dmidecode -t 17
6. htop Command
It is similar to top
command. It also displays memory and CPU usage per process. Use htop
command in terminal to display memory and CPU usage per process.
htop