▷ 6 Easy Ways to Check Memory Usage in Linux » 【2023】

Linux comes with many built-in tools to manage and optimize your system. Whether you’re new to Linux or just left Windows behind, there are a few commands you need to learn to get the most out of it. Linux is primarily known for being an operating system where the user or administrator has full control. Whether you use Ubuntu, Mint, Debian, or any other Linux distribution, you can do it all with the right commands and tools.

In this article, we will focus on how to check memory usage in Linux, as this is an important skill to have. Sometimes apps will start hogging all your system memory and you will need to know what troubleshooting steps you need to follow to find the problem. So here are the best command line tools to check memory usage on your Linux system.

Check Memory Usage in Linux

1. The “up” command

The top command line tool will give you a summary of all running processes. This summary includes real-time information about memory usage, so you can also use it as a monitoring application. You can see the total amount of system memory used, then you can check the list of processes to check the amount of memory used by each process.

To run this tool, just type the command above:

$ up

The top command shows you the total and free amount of memory on your Linux system, as well as the physical and swap memory used. The most important column, in this case, is %MEM because it tells you how much physical memory each process uses. You can then identify the rogue app that is consuming too much memory and remove it.

You can also use the command line tool above to check CPU usage. Just check the %CPU column to see the processing power used by each application.

2. The “free” command

If all you need to know about your system’s memory usage is the amount of free and used memory, you don’t really need the above command. The free remote will suffice. Kind free in the terminal and instantly know how much physical and swap memory is free or used. At the same time, it gets information about the buffers used by the kernel.

Note that memory usage information is not displayed in real time. You can use the free command line to monitor memory usage. It’s basically a screenshot that tells you how much memory was free or used when you typed the command. Use the above command if you want to monitor memory usage or know how much memory each process is using.

3. The “htop” command

The htop command is essentially the top command tool with an easier to read environment and easy to use commands. It shows real-time RAM usage, gives you a list of all running processes, and gives you shortcuts to commands that control processes. Once you see that the process is consuming too much RAM, you can hit the hotkey to kill it instead of using Bash commands.

To use the htop command, you must type at the top in terminal That said, you might get an error if your Linux distribution doesn’t come with this tool by default. In this case, type the following command to install it:

$ sudo apt-get install htop

4. The “vmstat” command

The vmstat command will display the virtual memory statistics report. The command will give you more information than you probably need, but if you’re thinking of becoming a Linux system administrator, you need to know this. The report includes the following information:

  • The number of processes (procs) this way while running.
  • The amount of swapped memory, free memory, cache, and buffer.
  • Blocks received and sent to a block device (IO).
  • CPU time (user time, system time, idle time).

Kind vmstat in the terminal to get the virtual memory statistics report.

5. Check the “proc/meminfo” file

You’re probably wondering where your Linux system gets all those RAM usage reports and information. Well, almost every command line tool you’ve used so far has the same source: the virtual proc/meminfo file. If you want to go directly to the source and get all the memory usage information you want, you can easily access the file by typing the following command:

minus /proc/meminfo

The report is quite long, so you should use the less to get some navigation control to quickly scan the output for the data you need. That said, this detailed report contains a lot of information that you probably don’t need. Here are the most important values ​​to focus on:

  • MemTotal
  • free memory
  • MemAvailable
  • buffers
  • cached
  • swap cache
  • Total exchange
  • Free exchange

6. Use the GUI

Linux purists may be against using the GUI over command line tools, but having a visual representation of RAM usage is great. You can get all the information you need and monitor your system’s memory usage in real time using the Linux System Monitor application.

To use the app, type “System Monitor” in the Start menu search bar and press Go in. System Monitor has two tabs of interest to us: the Processes and Resources tabs.

In the Processes tab, you can see all the processes running on your Linux operating system. You can read memory usage, CPU usage and other data for each individual process. This is where you can tell if any of the apps have gone rogue and are using too much RAM. You can then kill the process from the same window by right-clicking on it and selecting the kill option.

That said, if all you need to know is how your system’s memory and CPU performed, you should check out the graph display on the Resources tab.

Here you can see CPU, RAM and network history in the form of a graph. This means that you get historical data about your system’s memory usage over a certain period of time and you can also monitor that usage in real time.

How do you prefer to check memory usage on your Linux operating system? Do you know of any other commands and tools that can get more valuable data for analysis? Let us know in the comments below!