Memory is an essential component of your Linux system. All programs and files will be copied into RAM at some point, which makes it a precious resource to have. In this tutorial, we will show you how to monitor the RAM usage in your system with a few important commands in Linux.
top command is a useful tool that displays information about memory usage and each service utilizing it. To monitor the RAM usage simply execute:
To sort the output by memory usage you can press the m key. To exit from top, just press q.
htop is a interactive tool with an easy-to-read breakdown of current memory usage, along with other relevant system information.
htop doesn’t come installed by default on Linux. To install it:
$ sudo apt install htop # Debian/Ubuntu $ sudo dnf install htop # Fedora/Alma/Rocky/CentOS $ sudo pacman -S htop # Arch Linux / Manjaro
To view the memory usage using this command, execute:
You can use your mouse to click on the memory column (MEM%) to sort processes by their memory usage. To exit from htop, just press q.
As its name implies, the
free command is used to display the total amount of free memory. At the same time it also shows the total amount of used system memory. To use this command, execute:
If you want the output to be more easy to read, you can add the
-h (human-readable) option to the command.
$ free -h
Or if you prefer the output to be displayed in megabytes only, simply add the
-m flag to the command:
$ free -m
Another useful command tool that helps you display information about the virtual memory statistics and memoy usage. To use this command execute:
If you want to display a summary of the memory usage instead, add the
-s parameter to the command:
$ vmstat -s
The /proc/meminfo file
In this file we can find all the important information about the total amount of the free and used system memory. To view the content of this file you can use the
$ cat /proc/meminfo
Monitoring RAM Usage Linux via GUI
There are a lot of GUI applications available on Linux that can monitor RAM usage, in case you would prefer them over looking at the terminal. A good one for everyday use is GNOME System Monitor. Here’s how to install it:
$ sudo apt install gnome-system-monitor # Debian/Ubuntu $ sudo dnf install gnome-system-monitor # Fedora/Alma/Rocky/CentOS $ sudo pacman -S gnome-system-monitor # Arch Linux / Manjaro
Then open the application or launch from terminal:
You can see current RAM usage under the ‘Resources’ tab.