Updated October 2024: Stop getting error messages and slow down your system with our optimization tool. Get it now at this link
- Download and install the repair tool here.
- Let it scan your computer.
- The tool will then repair your computer.
How can I check used and free RAM usage on Linux operating systems using command line and GUI tools?
Linux comes with several sets of commands to check memory usage. The free command displays the total amount of free and used physical and swap memory in the system, as well as the buffers used by the kernel. The vmstat command reports information about processes, memory, paging, I/O blocks, traps, and processor activity. Finally, you can use the top, and/or atop/htop commands, which provide a dynamic, real-time view of a running system. top and friends can display summarized information about the system and a list of tasks currently managed by the Linux kernel.
Under Linux, there are commands for almost everything, as the GUI is not always available. When working on servers, only shell access is available and everything has to be done with these commands. So today we will review the commands that can be used to check memory usage on a Linux system. Memory includes RAM and swap.
It is often important to check memory usage and memory used per process on servers so that resources are not exhausted and users can access the server. For example, a Web site. If you are using a web server, it must have enough memory to serve visitors to the site. Otherwise, the website would become very slow or even crash during peak traffic simply because there is not enough memory. It’s just like your desktop PC.
Use the Free Command
However, sometimes the tip may be a little too high for your needs. You may just need to see the amount of free and used memory on your system. The free command is available for this. The free command is displayed:
- Total amount of free and used physical memory
- Total amount of swap memory in the system
- Buffers and covers used by the core
Launch the command from your terminal window. This command is not issued in real time. Instead, you get a snapshot of the free and used memory at that moment.
October 2024 Update:
You can now prevent PC problems by using this tool, such as protecting you against file loss and malware. Additionally, it is a great way to optimize your computer for maximum performance. The program fixes common errors that might occur on Windows systems with ease - no need for hours of troubleshooting when you have the perfect solution at your fingertips:
- Step 1 : Download PC Repair & Optimizer Tool (Windows 10, 8, 7, XP, Vista – Microsoft Gold Certified).
- Step 2 : Click “Start Scan” to find Windows registry issues that could be causing PC problems.
- Step 3 : Click “Repair All” to fix all issues.
Of course, you can make free a little more user-friendly by adding the -m option, like this: free -m. This will allow you to specify the memory usage in MB.
If your system is modern, even remotely, you will of course want to use the -g (gigabyte) option, as in free -g.
If you need amounts of memory, you can add the t option like this: free -mt. This simply adds up the amount of memory in columns.
Use the vmstat command
To view memory statistics using the vmstat command, you can use it as follows:
vmstat -s
The flag provides detailed statistics on memory usage.
In the output, you can display the free memory and the input of the free swap memory, which indicates the available memory in your system.
Check process memory usage with pmap
The pmap command allows you to check the memory of a process or set of processes in a human-readable format (in KB or kilobytes). All you need to know is the PID of the processes whose memory consumption you want to check.
For example, suppose you want to check how much memory the process uses with PID 917. To do this, run pmap as follows:
$ sudo pmap 917
As you can see, the total memory used by the 917 process is 516104 KB or kilobytes. You can also see here the amount of memory used by the libraries and other files that are required to run the process with PID 917.
Checking memory usage under Linux using the ps_mem command
ps_mem is a simple Python script that allows you to accurately determine the main memory usage of a program running under Linux.
This can determine how much RAM is used per program (not per process).
It calculates the total amount of memory used per program, sum = sum (private RAM for program processes) + sum (shared RAM for program processes).
Calculating shared RAM is problematic, and the tool automatically selects the most accurate method available for the kernel being executed.
Conclusion
This guide provides several options for checking memory usage on your Linux system. We have learned that one command provides a wealth of valuable data for future analysis. It is important that you learn how to interpret the information correctly.
Now you can manage your server more efficiently.
5 Commands for Checking Memory Usage in Linux
Expert Tip: This repair tool scans the repositories and replaces corrupt or missing files if none of these methods have worked. It works well in most cases where the problem is due to system corruption. This tool will also optimize your system to maximize performance. It can be downloaded by Clicking Here