Commands To Check Memory Usage On Linux/Ubuntu

Spread the love

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.

free-m command to see memory usage in MB in Linux/ubuntu

** If you want to see memory usage in MB, use free-g 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.

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

vmstat command

Use vmstat if you want to see memory statistics in default format.

vmstat -s

vmstat-s command

Use vmstat -s if you want to memory statistics in a single column. We recommend to use vmstat-s command as its report is easier to understand.

 

3. top Command

top command display 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.

top command in linux

**If you want to sort usage per process by memory used, use top -o %MEM command in terminal.

top-command-by-memory-usage

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

dmidecode Command in Linux

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

dmidecode Command

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

 

Disclosure: This website is supports by its reader. This means, if you buy any product / service through link on this website, we may earn a small commision withought costing you extra. Learn how you can support Us and why we need this?