how to find RAM info in linux including size, speed and type
Sometimes you will need to find specific information about the memory or RAM (Random Access Memory) on your computer. The RAM info in linux will contain various things like the speed, size, type, data width, vendor id among others. This can especially be useful if you are planning to upgrade the machine and need to know the exact version as supported and details of the memory currently installed.
There are two easy to use commandline options available that can show you all the required information: dmidecode and lshw.
Using dmidecode
The best commandline option to find ram info in linux is the dmidecode utility. This utility decodes and prints the DMI (Direct Media Interface) or SMBIOS information into a human readable format. Issuing the dmidecode command without any options will print out all the information about every hardware component on the system.
There are over 40 different components that are supported, with each of them given a specific name and number. You can use the keyword memory to print out all the RAM related information. This option will print out the following types from the DMI table:
5 | Memory Controller |
6 | Memory Module |
16 | Physical Memory Array |
17 | Memory Device |
All of the above type corresponds to some kind of information about the RAM.
bash$ dmidecode --type memory
If you just like to see the information about the memory device, then use the type number 17 as below.
bash$ dmidecode -t 17
The above command prints out all the information, including speed, size, type, asset tag, data width etc etc, regarding the RAM memory. You can sift through the details to find all the information that you need.
Size
The size of each of the memory slot can printed out by filtering the output using the grep command. The following command will print out size of the memory in each slot along with the slot handle address.
bash$ dmidecode --type memory | grep -i -e DMI -e size
If you are only interested in the size and usage of the RAM, then you can use other commands, such as free. Refer to this post on how to find the RAM or memory usage on your system.
Speed
As with the size above you can filter on speed to find the speed of your memory.
bash$ dmidecode --type memory | grep -i -e DMI -e speed
Type
The other interesting or useful information is the type of memory you have. You can find that from the field labeled Form Factor. The following command will filter that out.
bash$ dmidecode --type memory | grep -e DMI -e Form
You can use the following command to print out all the above information together
bash$ dmidecode --type memory | grep -e DMI -e Form -e Type -e Size -e Speed
Sample Output:
Handle 0x0018, DMI type 17, 27 bytes\\ Size: 2048 MB\\ Form Factor: DIMM\\ Type: DDR2\\ Type Detail: Synchronous\\ Speed: 800 MHz\\ Handle 0x001A, DMI type 17, 27 bytes\\ Size: 1024 MB\\ Form Factor: DIMM\\ Type: DDR2\\ Type Detail: Synchronous\\ Speed: 800 MHz\\ Handle 0x001C, DMI type 17, 27 bytes\\ Size: 2048 MB\\ Form Factor: DIMM\\ Type: DDR2\\ Type Detail: Synchronous\\ Speed: 800 MHz\\ Handle 0x001E, DMI type 17, 27 bytes\\ Size: 1024 MB\\ Form Factor: DIMM\\ Type: DDR2\\ Type Detail: Synchronous\\ Speed: 800 MHz
The above command prints out the information from the DMI table, without actually probing each hardware device. While this makes it faster and easier, it can also be unreliable. It is always better to crosscheck the information with the labels and markings on the hardware itself.
If you are just looking for information on finding the amount memory used then you can use the free command or any of the other utilities.
Using lshw
Another option to find ram info in linux is to install and use the lshw utility. This also has a easy to use graphical user interface. This utility pretty much shows the same information as the dmidecode command. When used from the command line without any options, it prints out information about all the devices.
Use the class (-class or -C or -c) option to further filter the output based on device classification. Using the memory class will display only data pertaining to BIOS, RAM and extension ROM.
bash$ lshw -class memory
You can use grep, as with the examples above, to filter the output to display only the size or speed.
bash$ lshw -c memory | grep -e clock -e size -e "*-"
The above command will print out only the lines which depict the clock (or speed) and the size of the memory in each slot. You may add additional options to print more information.