Linux, BSD, and *nix operating systems in general, give you plenty of options to view internal information. Just open up a terminal and type
cat /proc/meminfo or
cat /proc/net/wireless. Although data found in such places might be comprehensive, it’s not easy to read. Let’s see some utilities that show memory usage in a much more human readable format.
Note: while the instructions here are meant for Ubuntu, most, if not all, of them are applicable for other Linux distros, too.
Graphical Utilities to Check RAM Usage
Ubuntu, by default, includes an application called System Monitor. You can access it by going to the bottom-left “Show Applications” button and then typing “monitor” to search for it.
If it isn’t installed on your distribution, you can install it with:
sudo apt install gnome-system-monitor
Gnome System Monitor
The application has three tabs to view information about processes, resources and file systems. The Process tab is useful not just to see memory usage – you can also right click on programs and change their CPU usage priority, force-close misbehaving ones, etc.
In the Resources tab, you can view CPU load, memory and swap usage, and network activity.
Sometimes you may want to monitor memory usage as you open or use programs. Right-click on the top (title) bar of the window and select “Always on Top.” This will keep the window visible at all times, even if you open a full-screen program. You can use the same trick with
htop or other utilities you open in a terminal emulator window.
Another popular solution to keep an eye on system resources is Conky. This becomes part of your desktop background, which means it’s always active, letting you take a peek at any time. Install it with:
sudo apt install conky-all
By default, it shows up in the left side of the screen. That’s not good, as the side application bar would cover it. Let’s move it to the right:
cp /etc/conky/conky.conf ~/.conkyrc && sed -i 's/left/right/' ~/.conkyrc
Open up a terminal and type:
Of course, the defaults are very basic and raw and aren’t pretty to look at either. But the utility is very versatile and can show many more system stats. Furthermore, some themes people have created are very beautiful. To learn more about how to configure the utility, read about how you can use Conky Manager.
Check Free Memory with Command Line Utilities
Sometimes a graphical user interface is not available: for example, on servers. In such cases, there are command line utilities that can display memory usage information.
The “free” Utility
Open up a terminal emulator and type the following command.
The output may be misleading for those coming from a Windows background. Here, “free” doesn’t mean the amount that your applications have at their disposal. That’s because of “buff/cache.” When the operating system reads a file from your hard-disk or SSD, it keeps its data in RAM. This way, when it needs to read the file again, it can skip accessing your slower storage device and read from the much faster RAM. That’s why if you open your browser, close it, and open it again, it loads much faster the second time.
Even though the buffer and cache may use almost all of your RAM, you can still consider that portion of memory free. That’s because as soon as an application requires more RAM, some buffer/cache data is instantly deleted to free up memory for your program.
Consequently, the most important fields here are “used” and “available.” The first reflects how much RAM your programs are using, and the second how much RAM is available to applications that require it. This is what you can consider RAM that is actually free. These concepts of “free,” “used” and “available” are used in some graphical applications, too.
The “top” and “htop” Utilities
Another command, usually available out of the box on Linux systems, is
top. You can type
top in a terminal to open it. Press q to quit. But, as you can see from the following picture, it can be a little hard to read.
This is why a lot of people prefer a more eye-friendly version, called htop. Install it first.
sudo apt install htop
Launch the program.
As you can see, htop is much easier to read, thanks to its use of colors and bar graphs. The first bars, preceded by numbers such as “1,” “2,” etc., reflect CPU core usage. In the memory bar you can pay attention only to the green lines. The other two colors, the blue and the brown lines, reflect file and directory buffers and cache. As discussed in the previous section, these can be evicted from memory at any time so that portions of RAM can be considered free to use.
Besides using your keys to interact with htop, you can also use your mouse pointer to click on the elements displayed.
These are the most popular applications that display how memory is used. You can sort processes by the amount of RAM they use. You may find you don’t need some applications that eat up a lot of memory, and you can remove them from your system.
Our latest tutorials delivered straight to your inbox