Knowing the physical memory details of your Linux system can help you monitor memory usage, troubleshoot performance issues, or plan for hardware upgrades. Linux provides various commands to check the total memory, available memory, and other detailed information about the system's physical memory.
Different tools are available to view these details, each offering specific information about the system’s memory. These tools include basic commands like free and top for general memory status and more advanced ones like dmidecode to display hardware-level information about installed memory modules. These commands are accessible directly from the terminal and do not require any special configuration.
This article outlines several commands to help you display and analyze the physical memory details on a Linux system. These commands provide information such as total memory size, memory type, speed, and usage statistics.
Steps to display memory details in Linux:
- Open the terminal on your Linux system.
- Check the total and available memory using the free command.
$ free -h total used free shared buff/cache available Mem: 15Gi 2.3Gi 9.6Gi 221Mi 3.3Gi 12Gi Swap: 2.0Gi 0B 2.0Gi
This command shows the total, used, and available memory in human-readable format (MB or GB).
- Use the top command to display real-time memory usage.
$ top top - 10:20:34 up 1:15, 2 users, load average: 0.32, 0.44, 0.55 Tasks: 199 total, 1 running, 198 sleeping, 0 stopped, 0 zombie %Cpu(s): 3.2 us, 1.3 sy, 0.0 ni, 94.5 id, 0.7 wa, 0.1 hi, 0.1 si, 0.0 st MiB Mem : 15712.0 total, 2350.5 used, 9847.2 free, 223.1 shared, 3514.3 buff/cache MiB Swap: 2048.0 total, 0.0 used, 2048.0 free
Press `q` to exit the top command. This tool also displays the running processes and how much memory each process is consuming.
- View detailed hardware information about the installed memory using dmidecode.
$ sudo dmidecode --type memory Memory Device Size: 8192 MB Form Factor: DIMM Type: DDR4 Speed: 3200 MHz Manufacturer: Samsung Serial Number: 1234567890 Part Number: ABCD1234XYZ ...
The dmidecode command provides in-depth details about each memory module, such as size, speed, manufacturer, and type (e.g., DDR4, DDR5).
- Display memory information from the proc file system.
$ cat /proc/meminfo MemTotal: 15712000 kB MemFree: 10035200 kB MemAvailable: 12567000 kB Buffers: 512000 kB Cached: 3000000 kB SwapTotal: 2048000 kB SwapFree: 2048000 kB
This command shows raw data about memory usage and allocation directly from the kernel.
- Use the vmstat command to display memory statistics.
$ vmstat -s 15712000 K total memory 2350500 K used memory 9847200 K active memory 512000 K buffer memory 2048000 K total swap 0 K used swap
The vmstat command provides detailed statistics about system memory usage, including free memory, used memory, and memory buffers.
- Get a summary of memory usage and other system resources using the htop command.
$ htop Mem[||||| 2.34G/15.7G] Swp[ 0K/2.0G]
If htop is not installed, use your package manager to install it:
$ sudo apt install htop #Ubuntu $ sudo yum install htop #CentOS
Mohd Shakir Zakaria is an experienced cloud architect with a strong development and open-source advocacy background. He boasts multiple certifications in AWS, Red Hat, VMware, ITIL, and Linux, underscoring his expertise in cloud architecture and system administration.
Comment anonymously. Login not required.