Please keep in mind - many solutions in this post will only show how much memory the operating system detects (e.g. 32bit without PAE can only see 4GB)
Detect memory slots and state using dmidecode
Assuming you have sudo permissions you can use the dmidecode command to detect the amount of memory slots and what is inserted into them right now.
Example usage:
sudo dmidecode
Or even better, filtered just for memory related informations:
sudo dmidecode -t 17
Outputs in my case:
# dmidecode 3.0
Getting SMBIOS data from sysfs.
SMBIOS 2.7 present.
Handle 0x002F, DMI type 17, 34 bytes
Memory Device
Array Handle: 0x002D
Error Information Handle: Not Provided
Total Width: 64 bits
Data Width: 64 bits
Size: 4096 MB
Form Factor: DIMM
Set: None
Locator: ChannelA_Dimm1
Bank Locator: ChannelA
Type: DDR3
Type Detail: Synchronous
Speed: 1333 MHz
Manufacturer: A-DATA
Serial Number: 0000762C
Asset Tag: ChannelA_Dimm1_AssetTag
Part Number: DDR3 1600G
Rank: 2
Configured Clock Speed: 1333 MHz
Handle 0x0031, DMI type 17, 34 bytes
Memory Device
Array Handle: 0x002D
Error Information Handle: Not Provided
Total Width: 72 bits
Data Width: 64 bits
Size: No Module Installed
Form Factor: DIMM
Set: None
Locator: ChannelA_Dimm2
Bank Locator: ChannelA
Type: Unknown
Type Detail: Synchronous
Speed: Unknown
Manufacturer: ChannelA_Dimm2_Manufacturer
Serial Number: ChannelA_Dimm2_SerNum
Asset Tag: ChannelA_Dimm2_AssetTag
Part Number: ChannelA_Dimm2_PartNum
Rank: Unknown
Configured Clock Speed: Unknown
Handle 0x0033, DMI type 17, 34 bytes
Memory Device
Array Handle: 0x002D
Error Information Handle: Not Provided
Total Width: 64 bits
Data Width: 64 bits
Size: 4096 MB
Form Factor: DIMM
Set: None
Locator: ChannelB_Dimm1
Bank Locator: ChannelB
Type: DDR3
Type Detail: Synchronous
Speed: 1333 MHz
Manufacturer: A-DATA
Serial Number: 000028C3
Asset Tag: ChannelB_Dimm1_AssetTag
Part Number: DDR3 1600G
Rank: 2
Configured Clock Speed: 1333 MHz
Handle 0x0035, DMI type 17, 34 bytes
Memory Device
Array Handle: 0x002D
Error Information Handle: Not Provided
Total Width: 72 bits
Data Width: 64 bits
Size: No Module Installed
Form Factor: DIMM
Set: None
Locator: ChannelB_Dimm2
Bank Locator: ChannelB
Type: Unknown
Type Detail: Synchronous
Speed: Unknown
Manufacturer: ChannelB_Dimm2_Manufacturer
Serial Number: ChannelB_Dimm2_SerNum
Asset Tag: ChannelB_Dimm2_AssetTag
Part Number: ChannelB_Dimm2_PartNum
Rank: Unknown
Configured Clock Speed: Unknown
Handle 0x0037, DMI type 17, 34 bytes
Memory Device
Array Handle: 0x002D
Error Information Handle: Not Provided
Total Width: 64 bits
Data Width: 64 bits
Size: 4096 MB
Form Factor: DIMM
Set: None
Locator: ChannelC_Dimm1
Bank Locator: ChannelC
Type: DDR3
Type Detail: Synchronous
Speed: 1333 MHz
Manufacturer: A-DATA
Serial Number: 000028E7
Asset Tag: ChannelC_Dimm1_AssetTag
Part Number: DDR3 1600G
Rank: 2
Configured Clock Speed: 1333 MHz
Handle 0x0039, DMI type 17, 34 bytes
Memory Device
Array Handle: 0x002D
Error Information Handle: Not Provided
Total Width: 72 bits
Data Width: 64 bits
Size: No Module Installed
Form Factor: DIMM
Set: None
Locator: ChannelC_Dimm2
Bank Locator: ChannelC
Type: Unknown
Type Detail: Synchronous
Speed: Unknown
Manufacturer: ChannelC_Dimm2_Manufacturer
Serial Number: ChannelC_Dimm2_SerNum
Asset Tag: ChannelC_Dimm2_AssetTag
Part Number: ChannelC_Dimm2_PartNum
Rank: Unknown
Configured Clock Speed: Unknown
Handle 0x003B, DMI type 17, 34 bytes
Memory Device
Array Handle: 0x002D
Error Information Handle: Not Provided
Total Width: 64 bits
Data Width: 64 bits
Size: 4096 MB
Form Factor: DIMM
Set: None
Locator: ChannelD_Dimm1
Bank Locator: ChannelD
Type: DDR3
Type Detail: Synchronous
Speed: 1333 MHz
Manufacturer: A-DATA
Serial Number: 000028F0
Asset Tag: ChannelD_Dimm1_AssetTag
Part Number: DDR3 1600G
Rank: 2
Configured Clock Speed: 1333 MHz
Handle 0x003D, DMI type 17, 34 bytes
Memory Device
Array Handle: 0x002D
Error Information Handle: Not Provided
Total Width: 72 bits
Data Width: 64 bits
Size: No Module Installed
Form Factor: DIMM
Set: None
Locator: ChannelD_Dimm2
Bank Locator: ChannelD
Type: Unknown
Type Detail: Synchronous
Speed: Unknown
Manufacturer: ChannelD_Dimm2_Manufacturer
Serial Number: ChannelD_Dimm2_SerNum
Asset Tag: ChannelD_Dimm2_AssetTag
Part Number: ChannelD_Dimm2_PartNum
Rank: Unknown
Configured Clock Speed: Unknown
Invalid entry length (16). Fixed up to 11.
The output tells you about 8 slots, 4 being used, each featuring 4GB memory.
Detect memory using lshw
Assuming you have sudo permissions you can use the lshw command to detect the amount of memory slots and what is inserted into them right now.
As @Serg pointed out you should use awk to shrink the output down to the most essential
Example:
awk '/MemTotal/ || /SwapTotal/' /proc/meminfo
Output:
MemTotal: 16374920 kB
SwapTotal: 16715772 kB
Show memory informations using vmstat
You can use the vmstat command as well.
Example:
vmstat
Output:
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
3 0 4060888 238300 35576 11506488 0 2 120 55 17 4 18 6 74 2 0
It could be displayed more readable as follows:
vmstat -s -SM
Output:
15991 M total memory
4467 M used memory
5322 M active memory
9837 M inactive memory
253 M free memory
34 M buffer memory
11235 M swap cache
16323 M total swap
3965 M used swap
12358 M free swap
17691507 non-nice user cpu ticks
21078371 nice user cpu ticks
13384959 system cpu ticks
161496078 idle cpu ticks
4951342 IO-wait cpu ticks
0 IRQ cpu ticks
40582 softirq cpu ticks
0 stolen cpu ticks
263184336 pages paged in
119297582 pages paged out
1824 pages swapped in
1018199 pages swapped out
1111772384 interrupts
2371898713 CPU context switches
1473060064 boot time
1983609 forks
Monitoring ram usage
There are several tools which help monitoring ram/ memory usage. I'll name some here
top and htop are both tools which constantly update the current memory usage.
Using smem
smem reports usage with shared memory divided prportionally.
Good way to check is to reference /proc/meminfo file. Most tools such as free, top, htop all use that file.
There's many lines there showing different statistics, but using AWK, we can filter out the totals. MemTotal line will show you the RAM. As a bonus, I've included total Swap as well.
I like the output that sudo dmidecode -t 17 gives. Here's what it says about my machine:
# dmidecode 2.12
# SMBIOS entry point at 0x000f0480
SMBIOS 2.7 present.
Handle 0x0009, DMI type 17, 34 bytes
Memory Device
Array Handle: 0x0007
Error Information Handle: Not Provided
Total Width: 64 bits
Data Width: 64 bits
Size: 4096 MB
Form Factor: DIMM
Set: None
Locator: A1_DIMM0
Bank Locator: A1_BANK0
Type: DDR3
Type Detail: Synchronous
Speed: 1333 MHz
Manufacturer: Undefined
Serial Number: 000001D2
Asset Tag: A1_AssetTagNum0
Part Number: SLA302G08-EDJ1C
Rank: 2
Configured Clock Speed: Unknown
Handle 0x000D, DMI type 17, 34 bytes
Memory Device
Array Handle: 0x0007
Error Information Handle: Not Provided
Total Width: 64 bits
Data Width: 64 bits
Size: 4096 MB
Form Factor: DIMM
Set: None
Locator: A1_DIMM2
Bank Locator: A1_BANK2
Type: DDR3
Type Detail: Synchronous
Speed: 1333 MHz
Manufacturer: Undefined
Serial Number: 0000017F
Asset Tag: A1_AssetTagNum2
Part Number: SLA302G08-EDJ1C
Rank: 2
Configured Clock Speed: 2 MHz
I like the fact that it gives you a simple human-readable description of how much RAM is in each slot - 2 x Size: 4096 MB in the example above (so I have 8GB RAM total). And that it breaks it down by slot, so you have a bit more idea about what your upgrade options are.
dmidecode (man page) tells you about your system's hardware. Specifying -t 17 filters by the "Memory Device" type.
If you click on the gear icon (top right of your screen) then click on About this computer. The RAM is the 2nd entry down, below the computer name.
Edit
if you run
sudo lshw -class memory
in your terminal, this gives you the details of all available memory.Also easy to use commands to check RAM:
Using
top
command itself or:Similar to
top
but a bit more advanced ishtop
but the package has to be installedsudo apt-get install htop
then run:Will output memory scale in terminal.
Also
vmstat
can do this:In general
Please keep in mind - many solutions in this post will only show how much memory the operating system detects (e.g. 32bit without PAE can only see 4GB)
Detect memory slots and state using dmidecode
Assuming you have sudo permissions you can use the
dmidecode
command to detect the amount of memory slots and what is inserted into them right now.Example usage:
Or even better, filtered just for memory related informations:
Outputs in my case:
The output tells you about 8 slots, 4 being used, each featuring 4GB memory.
Detect memory using lshw
Assuming you have sudo permissions you can use the
lshw
command to detect the amount of memory slots and what is inserted into them right now.Example usage:
or just to get memory related informations:
Outputs in my case:
Show memory informations using free
You can use the
free
command to get informations about your memory.Example usage:
Output:
Add the
-h
parameter to get a more human readable outputIn case you want to monitor memory usage consider combining
watch
andfree
as followsThis will output the normal
free
output seen above, but update it all 2 seconds (usingwatch
)Show memory informations using /proc/meminfo
You can use
/proc/meminfo
to get some memory informations as well.Example:
Output:
As @Serg pointed out you should use
awk
to shrink the output down to the most essentialExample:
Output:
Show memory informations using vmstat
You can use the
vmstat
command as well.Example:
Output:
It could be displayed more readable as follows:
Output:
Monitoring ram usage
There are several tools which help monitoring ram/ memory usage. I'll name some here
top
andhtop
are both tools which constantly update the current memory usage.Using smem
smem
reports usage with shared memory divided prportionally.Example (sorted):
Output:
Good way to check is to reference
/proc/meminfo
file. Most tools such as free, top, htop all use that file.There's many lines there showing different statistics, but using AWK, we can filter out the totals. MemTotal line will show you the RAM. As a bonus, I've included total Swap as well.
Open a terminal: Ctrl +Alt + T
Then type:
sudo lshw
Open System Settings.
Click Details at the bottom of the panel.
You will see details about your PC (such as RAM).
I like the output that
sudo dmidecode -t 17
gives. Here's what it says about my machine:I like the fact that it gives you a simple human-readable description of how much RAM is in each slot - 2 x
Size: 4096 MB
in the example above (so I have 8GB RAM total). And that it breaks it down by slot, so you have a bit more idea about what your upgrade options are.dmidecode
(man page) tells you about your system's hardware. Specifying-t 17
filters by the "Memory Device" type.Please try:
Output will be something like: