Skip to content

How To: Retrieving System Serial Numbers and Hardware Information on Unix

cpx July 10, 2014 1 min read Hardware

Those snippets cover various methods to retrieve system serial numbers and hardware information across different operating systems and platforms.

dmidecode -t  1
wmic bios get serialnumber

pfexec ipmitool fru

prtfru /frutree/chassis/MB?Label=MB/system-board

prtdiag
prtconf
prtfru
psrinfo -v
sneep

# getconf CS_MACHINE_SERIAL
getconf CS_MACHINE_SERIAL: Invalid argument

# getconf MACHINE_SERIAL
getconf MACHINE_SERIAL: Invalid argument

# cstm
sh: cstm: not found.

# print_manifest
sh: print_manifest: not found.

#!/bin/bash

# Function to check command availability
command_exists() {
    command -v "$1" >/dev/null 2>&1
}

# Try various methods
get_serial() {
    # Try dmidecode
    if command_exists dmidecode; then
        echo "=== DMIDecode Method ==="
        sudo dmidecode -t 1 2>/dev/null | grep "Serial Number"
    fi

    # Try WMIC
    if command_exists wmic; then
        echo "=== WMIC Method ==="
        wmic bios get serialnumber 2>/dev/null
    fi

    # Try IPMI
    if command_exists ipmitool; then
        echo "=== IPMI Method ==="
        sudo ipmitool fru 2>/dev/null | grep "Product Serial"
    fi

    # Try system files
    if [ -f "/sys/class/dmi/id/product_serial" ]; then
        echo "=== System File Method ==="
        cat /sys/class/dmi/id/product_serial
    fi
}

# Execute
get_serial
0 0 votes
Article Rating
guest

0 Comments
Oldest
Newest Most Voted
0
Would love your thoughts, please comment.x
()
x