- Linux Free Memory Command
- Linux Command For Memory Info
- Linux Check Memory Usage
- Linux Check Memory Size
- Check Memory From Command Prompt
So today we shall be checking the commands that can be used to check memory usage on a linux system. Memory include RAM and swap. It is often important to check memory usage and memory used per process on servers so that resources do not fall short and users are able to access the server.
Random Access Memory or RAM in short, is a very important part of any computer. If you’ve bought a new pre-configured Ubuntu computer or a Virtual Private Server (VPS) and you don’t know any information about how much RAM it has, how much of it is used, the speed of the RAM installed, the type of the RAM, then this article is for you. In this article, I will show you how to find out information about your installed RAM or memory on Ubuntu 18.04 and also find out if you have any problems in your installed RAM. Let’s get started.
- @azorius (and probably unimplemented) means the bios/chipset can handle 4 slots, but the board manufacturer decided not to include 2 of the possible slots the bios can support in the physical realm that is the actual MB.
- Linux line commands enable you to gather all possible details about your computer's memory. You can even determine whether you can add extra memory to the computer without opening up the box. To list each memory stick and its capacity, issue the dmidecode command.
- Linux Command Check Memory Slots; You can get detailed info by typing the following cat command:! Use the isalist command to display a system's processor type!
- How to Check RAM Slots in Linux If the issue is with your Computer or a Laptop you should try using Reimage Plus which can scan the repositories and replace corrupt and missing files. This works in most cases, where the issue is originated due to a system corruption.
- Linux command to check memory slots For instance, you may get a $25 no deposit bonus with a 30x wagering requirement. This means you will have to wager a total of $750 – 30 times $25 – to cashout the maximum cap winning amount. 50x Gamble Responsibly BeGambleAware.org.
Checking Size and Availability of RAM
You can check how much RAM you have installed on your Ubuntu 18.04 machine using the following command:
As you can see from the marked section of the screenshot below, the total installed RAM on my Ubuntu 18.04 machine is 1.9 Giga Bytes (GB).
You can also find out how much RAM is used and how much RAM is available using free command.
As you can see from the marked section of the screenshot below, the RAM used on my Ubuntu 18.04 machine is 1.5 Giga Bytes (GB) and the RAM available or free is 258 Mega Bytes (MB).
Checking the Type and Speed of RAM
There are different types of RAM available in the market. For example, DDR1, DDR2, DDR3 and DDR4. DDR here means Double Data Rate. At the time of this writing, the most widely used RAM type is DDR3 and DDR4. There are other types of memory for portable devices as well such as SDRAM, DRAM etc.
Every RAM or memory module these days has different profiles. Each of these profile define the clock speed at which the RAM should be running.
You can check the type of RAM you have installed on your Ubuntu 18.04 machine using the following command:
You should see the following window as shown in the screenshot below. This is a lot of information. You can press the <Up> and <Down> arrow keys to navigate this information.
Just scroll down a little bit and you should find information about your RAM. As you can see from the screenshot below, the type of RAM installed on my Ubuntu 18.04 machine is DRAM.
You can also find out the clock speed or speed of the RAM installed on your machine using the dmidecode command. As you see from the marked section of the screenshot below. I don’t have the speed of my RAM listed here as I am using a Virtual Machine. But on real computers, it should be something like 1333 MHz or something like that.
Checking RAM for Errors
At times your RAM may suffer many issues as semiconductor devices like RAM are very fragile. You can check your RAM for errors.
On Ubuntu 18.04, you can use memtester command line utility to check your RAM for errors. memtester is not installed on Ubuntu 18.04 by default. But it is available in the official package repository of Ubuntu 18.04.
First update the package repository cache of your Ubuntu 18.04 machine with the following command:
The package repository cache should be updated.
Now you can install memtester on Ubuntu 18.04 with the following command:
memtester should be installed.
Now you can run memtester command to check memory as follows:
Here SIZE is the amount of memory to allocate and test using memtester utility. ITERATIONS is a number that specifies how many times you want memtester to test the allocated memory.
As SIZE you can use B for Bytes, K for Kilobytes, M for Megabytes and G for Gigabytes.
Let’s say you can to allocate 100 Megabytes in RAM and check it twice. You can run the following command to do that:
As you can see from the screenshot below, the memtester program is testing the RAM.
When memtester command is complete, as you can see from the screenshot below, all the tests are successful. It means the RAM has no errors. You can of course allocate more memory at once to perform a thorough test.
The only downside of memtester utility is that you can’t allocate more RAM than you have available as free.
You can use memtest86+ to do a more thorough check of your RAM. It has no such limitations as memtester. It is installed by default on Ubuntu 18.04.
Just reboot your Ubuntu machine and from the GRUB menu, select Memory test (memtest86+).
You should see the following window. Now press F1 to go to Fail-Safe Mode.
memtest86+ should start checking your RAM for errors as you can see from the screenshot below.
That’s how you find out different information about RAM and check RAM for errors on Ubuntu 18.04 Bionic Beaver. Thanks for reading this article.
These days, a computer can run many programs at once. The CPU has no problem handling all these programs because CPUs has multiple cores to handle multi-tasking.Each of these programs runs as one or more processes. Every process allocates some amount of RAM or memory for itself. It is essential for the process to function correctly. If a process fails to allocate enough RAM or memory, then the process can’t be created and the program won’t be able to start.
So, one of the basic task you do on your computer is to check how much memory or RAM (Random Access Memory) each of the process is using. Because, RAM or memory of your computer is limited.
Imagine a case, where you want to run some program and it fails because you don’t have enough memory. May be some of the processes are using a lot of memory that you don’t need right now. You can kill or stop these processes to free up RAM or memory, so that you can start your important programs.
In this article, I will show you how to check memory usage of each of the processes running on your Linux machine. I will be using Debian 9 Stretch for all the demonstration in this article. But it should work on any modern Linux distributions. Let’s get started.
You can use the ps command to check memory usage of all the processes on Linux. There is one problem with this procedure. ps don’t really show you how much memory a process uses in KB or MB format, but it will show you how much memory is being used in percentage.
You can check memory usage (in percentage) of all the process running on your Linux operating system with the following command:
As you can see, all the processes with memory usage in percentage is listed in descending order (The processes using most of the memory is listed first).
Checking Memory Usage of Processes with pmap:
You can check memory of a process or a set of processes in human readable format (in KB or kilobytes) with pmap command. All you need is the PID of the processes you want to check memory usage of.
Let’s say, you want to check how much memory the process with PID 917 is using. To do that, run pmap as follows:
As you can see, the total memory used by the process 917 is 516104 KB or kilobytes. You can also see how much memory the libraries and other files required to run the process with PID 917 is using as well here.
If you don’t care about how much memory the libraries or other dependent files are using, then run pmap as follows:
As you can see, only the total memory used by the process with PID 917 is printed on the screen.
If you want, you can further filter this with awk and get only the size in KB or kilobytes. To do that, run pmap as follows:
As you can see, only the memory usage in KB or kilobytes is printed.
Now you can also list how much memory is used by multiple processes using their PIDs with pmap as follows:
NOTE: Here 917 and 531 are process IDs or PIDs. You can put as many PIDs as you want this way.
Using pmap to List Memory Usage of All the Processes in Kilobytes:
In this section, I will show you how to write your own shell script to list memory usage of all the processes running on your Linux operating system in human readable format (kilobytes or KB).
First make a new file sysmon in your current working directory with the following command:
Now make the file executable with the following command:
sysmon is the shell script that will display all the running processes PID, OWNER, MEMORY (in KB in descending order) and COMMAND. Let’s start.
Open the sysmon script with your favorite text editor, I am going to use Kate.
Now, the first command I am going to run will give me the PID, OWNER and COMMAND of all the running processes separated by colon (:) symbol and store it in the RAWIN variable. Then loop through the output and print it on the screen.
As you can see, I am getting the correct output.
Now it’s time to process each line, store the colon delimited information in separate variables. That’s what I did on line 7, 8 and 9.
As you can see, I can print PID, OWNER and COMMAND in my own format now.
Linux Free Memory Command
Now it’s time to fetch memory usage of each PID. Line 10 does just that.
As you can see, everything is working perfectly. Now I can print memory usage of each process in kilobytes (KB) as well.
Linux Command For Memory Info
Now all that is left to do is format the output to look nice. I prefer table format. Line 5 prints the header of each column of the table.
Finally, I printed PID, OWNER, MEMORY (in KB) and COMMAND of each processes in a tabular format using line 14.
As you can see, it’s working kinda well. There is a little bit of problem though, the processes are not correctly sorted in descending order by memory usage.
To fix that, I removed sort -bnr -k3 from line 3 and wrapped everything in a shell function sysmon_main(). Then left the job of sorting to the sort command.
Linux Check Memory Usage
The final shell script looks something like this:
As you can see, it works great.
Now you can move it to somewhere like /usr/bin and execute it just like other commands as follows:
Linux Check Memory Size
Executing sysmon:
Check Memory From Command Prompt
Thanks for reading this article.