How To Check RAM Usage on Ubuntu
Checking RAM Usage with Command Line
Using free
The free
command is a quick and simple way to view memory usage statistics. It shows the total, used, and free amounts of physical memory and swap space, along with buffer and cache usage.
To check memory usage with free
, open a terminal and enter:
free -h
The -h
option provides human-readable output, making it easier to interpret the results. For continuous monitoring, you can use:
free -m -s 2
This command refreshes the output every two seconds, displaying the results in megabytes.
Using top
The top
command offers a dynamic, real-time view of system processes and their memory consumption. To use top
, simply type:
top
in the terminal. You can sort processes by memory usage by pressing Shift
+ >
until the %MEM
column is highlighted.
Using htop
htop
is an interactive process viewer that provides a more user-friendly interface than top
. If not already installed, you can install it with:
sudo apt install htop
Then, run it by typing htop
in the terminal. You can navigate through the list of processes and perform actions such as killing or renicing processes without needing to know their PIDs.
Using vmstat
vmstat
reports on virtual memory statistics. To use vmstat
, enter:
vmstat -s
This will display detailed memory statistics, including swap usage and system activity.
Using smem
smem
provides detailed memory usage reports, focusing on the proportional set size (PSS), which can give a more accurate representation of the memory used by processes. Install smem
with:
sudo apt install smem
and run it by typing smem
in the terminal.
Checking RAM Usage via GUI Tools
GNOME System Monitor
For a graphical approach, the GNOME System Monitor displays system resources, including memory usage. Open it by searching for “System Monitor” in the applications menu or by running gnome-system-monitor
from the terminal.
Glances
Glances is a comprehensive system monitoring tool that can be installed with:
sudo apt install glances
Run it by typing glances
in the terminal to view an overview of system resources, including RAM usage.
Nmon
Nmon is another monitoring tool that provides information on various system resources. Install it with:
sudo apt install nmon
and start it by typing nmon
. Press ‘m’ to switch to the memory statistics view.
Using the System Monitor to Check RAM Usage
The System Monitor displays the system’s resources in several tabs. The ‘Resources’ tab shows the RAM usage.
- Open the System Monitor.
- Click on the ‘Resources’ tab.
The ‘Memory’ section displays a graph of the memory usage over time. Below the graph, it shows the total, used, and free memory, as well as the available swap.
Conclusion
Whether you prefer command line tools or GUI applications, Ubuntu offers a variety of options for monitoring RAM usage. Regular checks can help you maintain an efficient and stable system, troubleshoot issues, and plan for upgrades when necessary. By following the detailed steps provided, you can effectively manage your system’s memory and ensure it is being used to its full potential.