In the Linux system, there are many ways to check the system memory size. Here are a few commonly used methods:
- Use the free command
free
The command can view information such as the total amount, usage, and free amount of system memory. Enter the following command in the terminal to view:
free -h
This command displays memory information in human readable form, for example:
total used free shared buff/cache available
Mem: 7.7G 2.4G 1.1G 1.1G 4.2G 4.3G
Swap: 2.0G 0B 2.0G
Among them, total
represents the total amount of memory, used
represents the amount of used memory, and free
represents the amount of free memory.
- use the cat command
/proc/meminfo
The file contains detailed information about system memory. You can cat
view the contents of this file with the command, as follows:
cat /proc/meminfo
This command outputs detailed information about system memory, such as
MemTotal: 8051920 kB
MemFree: 1172128 kB
MemAvailable: 4458368 kB
Buffers: 125528 kB
Cached: 4023852 kB
SwapCached: 0 kB
Active: 2927372 kB
Inactive: 2965436 kB
where, MemTotal
represents the total amount of memory in kilobytes.
- Use the dmidecode command
dmidecode
The command can display system hardware information, including memory information. Enter the following command in the terminal to view:
sudo dmidecode -t memory
This command will output detailed information of all memory modules in the system, for example:
# dmidecode 3.2
Getting SMBIOS data from sysfs.
SMBIOS 2.7 present.
Handle 0x1000, DMI type 16, 23 bytes
Physical Memory Array
Location: System Board Or Motherboard
Use: System Memory
Error Correction Type: None
Maximum Capacity: 32 GB
Error Information Handle: Not Provided
Number Of Devices: 4
Handle 0x1100, DMI type 17, 34 bytes
Memory Device
Array Handle: 0x1000
Error Information Handle: Not Provided
Total Width: 64 bits
Data Width: 64 bits
Size: 8192 MB
Form Factor: DIMM
Set: None
Locator: ChannelA-DIMM0
Bank Locator: BANK 0
Type: DDR3
Type Detail: Synchronous
Speed: 1600 MT/s
Manufacturer: Kingston
Serial Number: 123456789
Asset Tag: Not Specified
Part Number: KHX1600C9D3K2/8GX
Rank: 2
Configured Clock Speed: 1600 MT/s
Minimum Voltage: 1.5 V
Maximum Voltage: 1.5 V
Configured Voltage: 1.5 V
Where, Maximum Capacity
represents the total amount of memory in GB.