Before I order more RAM for a server, I want to know how many slots there are, what is in them and what speed it runs at. The firmware already knows, and dmidecode reads it out.
sudo dmidecode -t memory
-t memory shows the memory entries from the firmware’s DMI tables: the physical memory array and one block per memory device, with details such as size and speed. That tells you how many slots are in use, which is usually the answer I was after.
-t system works the same way for the system information. For one value only, use -s:
sudo dmidecode -s system-serial-number
Handy when you need the serial number for a warranty claim and the sticker is on the bottom of a machine in a rack.
The man page also notes that on Linux most of these strings can be read straight from sysfs, and that most of those files are readable by normal users. Good for a script that should not need sudo.
Caveat: the data comes from the vendor’s firmware, and the man page is honest about it: the information in the DMI tables is often inaccurate, incomplete or simply wrong. I’d double-check against the motherboard manual before buying anything.
Further reading: dmidecode manual