How to get the processor serial number under Linux without root privileges

How can I get the processor serial number under Linux (Ubuntu) without root privileges?

I tried the cpuid command, it works without root privileges, but it seems to return all zeros (I think because something needs to be changed in the BIOS).

Can you offer me another way to get the processor series from a program without root privileges and without having to change the BIOS?

+7
source share
7 answers

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

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

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

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

​​uuid root, :

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

Pentium III. Intel - , . , PIII BIOS , , , 0.

+4

cpuid , sudo:

 % cpuid | grep serial
Processor serial: 0002-0652-0000-0000-0000-0000
 % sudo cpuid | grep serial
Processor serial: 0002-0652-0000-0000-0000-0000

, ...?

+1

, , ( ), MAC-:

+1

inode, , . , .

, , ​​ .

. , .

+1

dmesg? /bin

0

; , DMI root ( , ):

dmesg | grep -i dmi: | cut -d ":" -f 2-

"" dmidecode :

sudo chmod +s /usr/sbin/dmidecode

, :

dmidecode -s system-serial-number

" " " " " ". , , , Debian , .

, , ; :

mount | grep "on / type" | awk '{print $1}'

, ( /dev/sda7), :

find /dev/disk/by-id/ -lname "*sda" ! -name "wwn*"

Thus, a complete command to search for a unique identifier on your system’s hard drive might be:

find /dev/disk/by-id/ -lname "*'mount | grep " / " | awk '{print $1}' | cut -b 6-8'" ! -name "wwn*" -printf "%f\n"

I hope this can fit your needs or someone else here. The cut -b 6-8 command may not be portable because I assume the block device names are three characters long; moreover, the path / dev / disk / by-id / path is filled only by managed UDEV systems, and not all Linux distributions use it, but I guarantee that the first ones will work in Ubuntu.

0
source

All Articles