Extract hardware serial number

Dear community,
I'm on RHEL 5. Is there a way to extract CPU S/N, or other hardware S/N from bash?

My goal will be create a license file based on that hardware S/N, and make the script executable only on a specific machine!
So any other hardware related advices are welcome!

Thanks
Lucas

First check out the model.

That kind of information is usualy obtained thru some vendor api commands like HP's hpasmcli coming with HP Proliant support pack for RHEL

For instance to get serial number :

hpasmcli -s "show server" | awk -F":" '/Serial No./ { print $NF } '

You might also want to take a look at dmidecode to get such information (of course you will have to parse it a bit to be used in scripts.)

Hope that helps
Regards
Peasant.

1 Like

dmidecode might be useful to retrieve such information from BIOS memory on PC Linux. It's not always the same, however.

1 Like

Thanks both, however, most probably, hpasmcli is ok for me! :b:

For anyone interested in dell you can use the following to get the system service tag and express service codes in bash:

echo "Service tag: $(dmidecode -s system-serial-number)"
echo "Express service code: $((36#$(dmidecode -s system-serial-number)))"

Note: requires the dmidecode package installed ( # yum install dmidecode )

1 Like

Thank you, but I forgot to mention that RHEL runs on HP Blade 460, so HP utilities help me a lot to exctract serial numbers! :wink: