>_cmd.script

dmidecode

Read hardware info from DMI/SMBIOS tables

System

By CMD Script Team · 4 min read · Last updated

SYNTAX
dmidecode [OPTIONS] [KEYWORD...]

Options

Command options and flags
FlagDescription
-tOnly display entries of a given type, e.g. -t memory, -t bios, -t system
-sPrint only the value of a single DMI string, e.g. -s system-serial-number
-qQuiet output: less verbose, omits unknown/unsupported entries
-uShow undecoded raw data values alongside decoded output
--typeLong form of -t; accepts a type name or numeric SMBIOS type ID
-VPrint the dmidecode version number and exit
-hShow usage help and exit

Distribution compatibility

  • Ubuntu
  • Debian
  • Fedora
  • Arch
  • macOS (not available)

What it does

dmidecode reads the DMI (Desktop Management Interface) table — also known as SMBIOS (System Management BIOS) — from your system's firmware and prints it in a human-readable format. This table is populated by the BIOS/UEFI at boot time and describes the physical hardware: motherboard model, BIOS version, installed RAM modules and their speeds, CPU socket population, chassis type, and serial numbers. It doesn't probe hardware directly; it just decodes whatever the firmware already recorded, so accuracy depends on how well the vendor filled in those fields.

Beginner examples

  • sudo dmidecode — dump the entire DMI table (long output, needs root)
  • sudo dmidecode -t bios — show only the BIOS section (vendor, version, release date)
  • sudo dmidecode -t system — show system manufacturer, product name, and UUID
  • sudo dmidecode -t memory — list installed memory modules and their sizes/speeds
sudo dmidecode -t system

Advanced examples

  • Get a single field without parsing full output: sudo dmidecode -s system-serial-number
  • Check maximum supported and currently installed RAM: sudo dmidecode -t memory | grep -E "Size|Speed|Maximum Capacity"
  • Show processor details including core/thread counts: sudo dmidecode -t processor
  • Combine with a keyword list to inspect several types at once: sudo dmidecode -t bios -t system -t baseboard
  • Filter for chassis/enclosure type (useful for detecting VM vs bare metal): sudo dmidecode -t chassis
sudo dmidecode -t memory | grep -A2 "Memory Device"

Common mistakes

  • Running dmidecode without sudo and assuming empty output means no hardware info exists — it almost always means a permissions failure reading /dev/mem.
  • Treating DMI values as always accurate; some vendors leave fields as Not Specified, To Be Filled By O.E.M., or simply wrong, especially on white-box or older hardware.
  • Expecting live/real-time data — DMI tables are a static snapshot written at boot, so a hot-swapped RAM module or CPU change won't show up until reboot.
  • Using dmidecode inside containers expecting real hardware data — containers share the host kernel but typically can't read /dev/mem, or they inherit the host's DMI info.

Tips

  • Use -t <type> instead of grepping the full dump; common types are bios, system, baseboard, chassis, processor, memory, and cache.
  • dmidecode --type memory accepts either the type name or the numeric SMBIOS type (e.g. 17 for memory devices) — useful in scripts that want a stable ID.
  • Combine with lscpu and lspci for a fuller hardware picture: dmidecode covers firmware-level info that lspci/lsusb (bus-enumerated devices) don't.
  • If a field is unpopulated, check dmidecode -t 0 through higher type numbers directly; some data may exist in a less common type entry.

Best practices

  • Always run with sudo/root in scripts, and check the exit code — a permission failure should be handled distinctly from "no such hardware."
  • Prefer -s <keyword> over full-table parsing in automation; it's stable across dmidecode versions and avoids fragile regex against decoded text blocks.
  • Cross-check critical inventory data (serials, asset tags) against a second source like lshw or vendor tooling, since DMI fields are firmware-supplied and can be inconsistent.
  • Avoid running dmidecode inside untrusted or shared VMs for inventory purposes; virtual firmware often reports placeholder or hypervisor-generic values.

Try it yourself

A simulated shell with a sample home directory — experiment freely, nothing leaves your browser. Type help to list supported commands.

Real-world use cases

  • Hardware inventory scripts that collect serial numbers, asset tags, and RAM configuration across a fleet of servers for asset management.
  • Diagnosing memory upgrade compatibility by checking dmidecode -t memory for slot count, populated slots, and maximum supported capacity before ordering more RAM.
  • Verifying BIOS/firmware version before applying a vendor firmware update, to confirm the update actually applied afterward.

Common interview questions

  • What is the difference between DMI and SMBIOS? SMBIOS is the specification that defines the data structures; DMI is the older name/interface for accessing that same table. In practice dmidecode reads SMBIOS data and people use the terms interchangeably.
  • Why does dmidecode need root privileges? It reads raw physical memory (/dev/mem) or a privileged sysfs table where the firmware wrote the DMI structures, which the kernel restricts to root for security reasons.
  • How would you find the maximum RAM a server supports without opening the case? sudo dmidecode -t memory | grep "Maximum Capacity" reads the firmware-reported ceiling directly from the DMI table.

Frequently Asked Questions

Why does dmidecode print nothing or say 'Permission denied'?

dmidecode reads directly from /dev/mem or the kernel's sysfs DMI tables, which requires root access. Run it with sudo dmidecode.

Is dmidecode available on macOS?

No. DMI/SMBIOS tables are a BIOS firmware standard used on PC-compatible hardware running Linux or Windows. Apple hardware doesn't expose this data the same way, so dmidecode isn't packaged for macOS; use system_profiler instead.

How do I get just the serial number or product name without parsing full output?

Use the -s flag with a keyword, e.g. dmidecode -s system-serial-number or dmidecode -s baseboard-product-name.

Can dmidecode run inside a virtual machine?

Yes, but the output reflects whatever the hypervisor exposes through its virtual firmware (e.g. QEMU/SeaBIOS, VMware BIOS), which is often generic or partially populated compared to real hardware.

Cheat sheet

Download a quick-reference cheat sheet for dmidecode.