Linux Memory Slots Info
- Linux Get Memory
- Linux Print Memory Info
- Get Memory Info Linux
- Linux Memory Slots Information
- Linux Memory Slots Info Free
It is essential that your Linux system runs at an optimal level. A few simple terminal commands provide access to all relevant information and help you monitor memory statistics.
- It provides information on installed drives not the actual number of slots the machine has. There are commands where it will provide the slot number associated with the installed hard drive but I want to know if there is a command that can provide information on how many drive slots there are in the machine regardless of if there are hard drives installed or not.
- The RAM, for Random Access Memory, is a critical component of a Linux system that needs to be monitored closely. In some cases, you might run out of memory, leaving your server with very slow response times or being completely unresponsive. As a consequence, knowing how to check your RAM on Linux is crucial because you might be able to take preventive actions instead of corrective ones.
Once run, you can find information about memory at Memory and SPD tabs, where the memory slot selection will show you the available slots, used and free.
In this tutorial, learn five powerful commands to check memory usage in Linux.
We also provide detailed explanations of what they do and more importantly, how to interpret the results. The commands will work with nearly all Linux distributions. In this instance, the commands and the results are presented using Ubuntu 18.04
- Access to a command line / terminal
- User with sudo privileges
- The apt package manager
Entering cat /proc/meminfo
in your terminal opens the /proc/meminfo file.
This is a virtual file that reports the amount of available and used memory. It contains real-time information about the system’s memory usage as well as the buffers and shared memory used by the kernel. The output might differ slightly based on the architecture and operating system in question.
This is an example of what the /proc/meminfo file looks like in Ubuntu 18.04:
The terminal displays the information in kilobytes.
free Command to Display the Amount of Physical and Swap Memory
Typing free
in your command terminal provides the following result:
The data represents the used/available memory and the swap memory figures in kilobytes.
total | Total installed memory |
used | Memory currently in use by running processes (used= total – free – buff/cache) |
free | Unused memory (free= total – used – buff/cache) |
shared | Memory shared by multiple processes |
buffers | Memory reserved by the OS to allocate as buffers when process need them |
cached | Recently used files stored in RAM |
buff/cache | Buffers + Cache |
available | Estimation of how much memory is available for starting new applications, without swapping. |
Compared to the /proc/meminfo file, the free
command provides less information. However, it is easier to understand. The key figure being the available value as it displays how much memory is still available for running new applications.
The free
command has multiple options to format the output so that it better matches your requirements. The table below lists the most useful variations of the free
command.
Options | Result |
-b | output in bytes |
– k | output in kilobytes |
– m | output in megabytes |
– g | output in gigabytes |
– l | detailed low and high memory statistics |
– o | old format (no -/+buffers/cache line) |
– t | total for RAM + swap |
– s | update every [delay] seconds |
– c | update [count] times |
Note: As with most commands, entering man free
displays an overview of all variations and descriptions of the results.
vmstat Command to Report Virtual Memory Statistics
The vmstat
command is a useful tool that reports virtual memory statistics.
vmstat
provides general information about processes, memory, paging, block IO, traps, and CPU activity.
The detailed description listed below provides an explanation for each value in case you need assistance in analyzing the results.
- Procs
- r: number of processes waiting for run time.
- b: number of processes in uninterruptible sleep.
- Memory
- swpd: amount of virtual memory used.
- free: amount of idle memory.
- buff: the amount of memory used as buffers.
- cache: amount of memory used as cache.
- Swap
- si: memory swapped in from disk (/s).
- so: memory swapped to disk (/s).
- IO
- bi: Blocks received from a block device (blocks/s).
- bo: Blocks sent to a block device (blocks/s).
- System
- in: number of interrupts per second, including the clock.
- cs: number of context switches per second.
- CPU – These are percentages of total CPU time.
- us: Time spent running non-kernel code. (user time, including nice time)
- sy: Time spent running kernel code. (system time)
- id: Time spent idle. Before Linux 2.5.41, this includes IO-wait time.
- wa: Time spent waiting for IO. Before Linux 2.5.41, included in idle.
- st: Time stolen from a virtual machine. Before Linux 2.6.11, unknown.
The top
command is useful to check memory and CPU usage per process. It displays information about:
- uptime
- average load
- tasks running
- number of users logged in
- number of CPUs/CPU utilization
- memory/swap system processes
The data is continuously updated, which allows you to follow the processes in real-time.
Aside from providing you with essential memory information, the top
command provides a limited interactive interface. It is possible to manipulate and configure operations by using command-line options.
The man top
command provides a comprehensive list of all available variations.
The information the htop
command provides is similar to the top
command. However, the real advantage to the htop
command is its user-friendly environment and improved controls.
The command uses color for its output, provides full command lines for processes, as well as the option to scroll both vertically and horizontally.
The following output appears:
- The top segment provides summary information and contains graphic meters and text counters.
- The lower section structures the detailed data, per process. This allows you to perform actions on individual processes with ease.
- The shortcuts listed at the bottom of the screen will enable you to manipulate and customize the processes quickly and without the need to type specific commands.
Note: If you run into “Command ‘htop’ not found” message when trying to run the htop command, you will need to install the htop
function first:
As an alternative, use the command below:
Using a graphical interface for server administration is not common practice. However, certain data sets are much clearer, with a visual representation of memory usage.
To access the System Monitor:
- Navigate to Show Applications.
- Enter System Monitor in the search bar and access the application.
- Select the Resources tab.
- A graphical overview of your memory consumption in real time, including historical information is displayed.
This guide provided several options to check memory usage on your Linux system. We learned that a single command provides an abundance of valuable data for future analysis. Learning to interpret the information correctly is critical.
Now you can administer your server more efficiently.
Next you should also read
This tutorial shows how to display disk usage from a command line in Linux. It is important to know how much…
The Linux kernel is much like the central brain of the operating system. Although it is open-source – meaning…
There are many different tools for monitoring network traffic on a Linux server. Each option has its…
Reducing server response time to the bare minimum is one of the primary goals of website owners and SEO…
You have probably noticed your Linux OS slowing down, especially when working harder. Understanding CPU…
Some time back I was using a command called meminfo in Solaris to find the memory information in Solaris. It is indeed a nice script written by schmidt http://www.4schmidts.com/memconf.html .
Later, I moved my role from supporting Solaris systems to Linux systems and I was struggling to get the same piece of info in Linux about the memory bank/slot and how memory is present in each memory bank. Today I got an audit work to validate the system data that someone has filled about Linux servers. So, this time I couldn’t escape and I had to find a way out. I always knew that there should be info in dmidecode command, but as usual my laziness was stopping me from looking in to the output.
So finally I had to push my lazy attitude and dive in to the Info which dmidecode was giving. I was really surprised to see that there is enough info that we can grab from the dmidecode output. So here is my analysis.
- First check the actual memory Info from the either “top” or “free -m” command.
- Check the “dmidecode” output for the DIMM slot and each RAM size
FREE COMMAND OUTPUT
So the below command shows that we have around 2GB of memory installed in the system.
[root@bravo]# free -m
total used free shared buffers cached
Mem: 2026 1585 440 0 222 551
-/+ buffers/cache: 811 1215
Swap: 4094 0 4094
TOP COMMAND OUTPUT
Let’s verify our understanding of memory available using the TOP command which also shows that we have approx 2GB memory approx.
[root@bravo]# top
top – 13:18:56 up 216 days, 4:12, 3 users, load average: 0.14, 0.11, 0.09
Tasks: 199 total, 1 running, 198 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.8% us, 1.4% sy, 0.0% ni, 97.4% id, 0.3% wa, 0.0% hi, 0.0% si
Mem: 2074900k total, 1623648k used, 451252k free, 227816k buffers
Swap: 4192924k total, 296k used, 4192628k free, 565160k cached
DMIDECODE COMMAND
Run the DMIDECODE command and look for the data where the word “Physical Memory Array” starts and go through each line to get detailed information. In some new systems you can also use the command dmidecode –s memory and dmidecode –t 17 , where “s” means string and “t” means type. Let’s just use dmidecode here for now.
Summary of the memory data
——————————————————————————————-
Maximum memory that the ON BOARD memoryslots can accept is= 8GB
Type of memory = DDR
Error Correction Type: Single-bit ECC
Size of each DIMM = 1024 MB (1GB)
DIMM Speed = 333 MHz (3.0 ns)
Number of DIMM slots = Total4 DIMM slots and only 2 DIMM slots are filled with 1GB memory each
Note: where ever the Memory module is not installed the “Size” would show as “Size: No Module Installed”
——————————————————————————————-
[root@bravo]# dmidecode more
So here is the summary of the Info that we are looking from the Important Information we have from the dmidecode data
Handle 0x1000
DMI type 16, 15 bytes.
Physical Memory Array
Location: System Board Or Motherboard
Use: System Memory
Error Correction Type: Single-bit ECC
Maximum Capacity: 8 GB
Error Information Handle: Not Provided
Number Of Devices: 4
Linux Get Memory
Handle 0x1100
DMI type 17, 23 bytes.
Memory Device
Array Handle: 0x1000
Error Information Handle: Not Provided
Total Width: 72 bits
Data Width: 64 bits
Size: 1024 MB
Form Factor: DIMM
Set: 1
Locator: DIMM 01
Bank Locator: Not Specified
Type: DDR
Type Detail: Synchronous
Speed: 333 MHz (3.0 ns)
Handle 0x1101
DMI type 17, 23 bytes.
Memory Device
Array Handle: 0x1000
Error Information Handle: Not Provided
Total Width: 72 bits
Data Width: 64 bits
Size: 1024 MB
Form Factor: DIMM
Set: 1
Locator: DIMM 02
Bank Locator: Not Specified
Type: DDR
Type Detail: Synchronous
Speed: 333 MHz (3.0 ns)
Linux Print Memory Info
Handle 0x1102
DMI type 17, 23 bytes.
Memory Device
Array Handle: 0x1000
Error Information Handle: Not Provided
Total Width: 72 bits
Data Width: 64 bits
Size: No Module Installed
Form Factor: DIMM
Set: 2
Locator: DIMM 03
Bank Locator: Not Specified
Type: DDR
Type Detail: Synchronous
Speed: 333 MHz (3.0 ns)
Handle 0x1103
DMI type 17, 23 bytes.
Memory Device
Array Handle: 0x1000
Error Information Handle: Not Provided
Total Width: 72 bits
Data Width: 64 bits
Size: No Module Installed
Form Factor: DIMM
Set: 2
Locator: DIMM 04
Bank Locator: Not Specified
Type: DDR
Type Detail: Synchronous
Speed: 333 MHz (3.0 ns)
So here is my learning for the day. So I am signing of for the day looking forward to learn something new tomorrow. Infact there are couple of things that I have learnt today and I would try to either share it today or tomorrow in my new post.
Get Memory Info Linux
Also, one thing that I started believing these days is that there is no job which is small or waste of time. We just have to look at the learning that we can grab from it. I am sure every job teaches us something might not be technical always but I am sure we would have some thing to learn from it directly or in directly.
Linux Memory Slots Information
Adios ! Amigos !
Linux Memory Slots Info Free
The desire to write grows with writing.Desiderius Erasmus