How to Use the dmidecode Command in Linux to Find Hardware Serial Numbers

Every piece of hardware inside a computer or server—the motherboard, the RAM modules, the CPU, and the chassis itself—contains deeply embedded manufacturer information. When managing a large fleet of Linux servers in a data centre, or attempting to verify warranty information for a remote machine, you often need to retrieve the serial numbers, manufacturer names, and exact model numbers of these components. Opening the server chassis to read the physical stickers is rarely practical. The Linux dmidecode command solves this by querying the system’s Desktop Management Interface (DMI) and SMBIOS tables to print this hardware information directly to your terminal.

Executing the Basic dmidecode Command

Because querying the hardware tables requires direct interaction with the system’s memory and BIOS, dmidecode must always be run with root privileges using sudo. Running the command without arguments will dump the entire SMBIOS table to your screen.

  1. Open your terminal or connect to the server via SSH.
  2. Execute the command: sudo dmidecode | less

Piping the output into less allows you to scroll through the massive block of text using your arrow keys. You will see detailed blocks of information for the BIOS, the system enclosure, the processor, and every individual memory slot. Press q to exit the less viewer.

Filtering by Specific Hardware Types

Dumping the entire table is rarely efficient when you are looking for a single serial number. The -t (or --type) flag allows you to filter the output to a specific hardware category using numerical codes or keywords. The most common keywords are bios, system, baseboard (motherboard), chassis, processor, and memory.

To view only the information about the computer’s motherboard (baseboard):

sudo dmidecode -t baseboard

The output will be concise, displaying the manufacturer (e.g., Dell Inc., Supermicro), the specific product model name, and the unique serial number stamped onto the board.

Extracting a Single Serial Number for Scripts

If you are writing a bash script to automatically inventory your servers, you do not want to parse the entire text block returned by the -t flag. You just want the exact string containing the serial number. The -s (or --string) flag allows you to extract exactly one specific field, making it perfect for automation.

To retrieve the primary System Serial Number (often required for warranty claims or identifying a bare-metal server in a rack):

sudo dmidecode -s system-serial-number

To retrieve the BIOS version currently installed:

sudo dmidecode -s bios-version

The output of these commands will be a single line of text containing only the requested value, which can easily be assigned to a variable in a shell script.

Understanding Virtual Machine Output

It is important to understand how dmidecode behaves if you execute it inside a Virtual Machine (VM) running on hypervisors like VMware, Hyper-V, or KVM. A virtual machine does not have direct access to the underlying physical hardware of the host server. It is presented with a “virtual” motherboard and a “virtual” BIOS. Therefore, running dmidecode -s system-manufacturer inside a VM will typically return strings like “VMware, Inc.” or “QEMU”, rather than the actual physical hardware manufacturer (like Dell or HP) hosting the hypervisor.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.