Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get CPU serial under Linux without root permissions

How can I get CPU serial number under Linux (Ubuntu) without root permissions?

I tried cpuid command, it works without root permissions, but appears to return all zeros (I believe because something needs to be changed in BIOS).

Can you please suggest me another way to retrieve CPU serial from a program without root permissions and without having to modify BIOS?

like image 683
Alexey Avatar asked Feb 18 '11 19:02

Alexey


2 Answers

Processor serial numbers were basically only in Pentium III processors. Intel removed it from later models due to the privacy concerns that were raised. As such, unless you're on a PIII AND your BIOS settings let you read the serial number, all you'll get are 0's.

like image 137
Marc B Avatar answered Oct 02 '22 00:10

Marc B


Root permissions required. The answer is dmidecode.
If you need CPU ID:

dmidecode | grep -w ID | sed "s/^.ID\: //g"

This will get CPU ID, remove 'ID: ' from output
If you need to receive a computer ID:

dmidecode | grep -w UUID | sed "s/^.UUID\: //g"

If you wish to get kernel uuid without root permissions, then:

dmesg | grep UUID | grep "Kernel" | sed "s/.*UUID=//g" | sed "s/\ ro\ quiet.*//g"

It's because of recent comment. Happened long time ago, so can't explain now why these ID were taken as machine identifier. Got actual Processor ID fromn Processor Information section. Extracted on Debian OS.

pr=0; dmidecode | while read line; do [ "$line" == "Processor Information" ] && pr=1; [ $pr -eq 0 ] && continue; [ -n "$(echo $line | grep '^ID')" ] && echo $line | awk -F"ID: " '{print $2}' && break; done
like image 23
ETech Avatar answered Oct 01 '22 23:10

ETech