Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

First of all, I would like to apologies for the title for not including hardware details. This is because I am looking for a command that will work in all Linux distribution.


I am very new to Linux and don't know much, however, is it possible to retrieve the hard drive serial number running as non-root. I am aware there are commands available to retrieve this information running using sudo. However, I need a way to retrieve this information without running as sudo.

Any suggestions would be highly appreciated.

Kind Regards,


share|improve this question

5 Answers 5

On most current distributions HDD serial numbers are stored in the udev database, which could be queried without root permissions:

/sbin/udevadm info --query=property --name=sda

(look for ID_SERIAL, ID_SERIAL_SHORT; there are also /dev/disk/by-id/ata-* symlinks for ATA drives based on those values).

udisks provides a higher-level interface to those data and more (it also gives access to SMART attributes without requiring root privileges, which would be needed for calling, e.g., smartctl directly).

share|improve this answer

Another way that usually works is:

ls -l /dev/disk/by-id/

Here's a one liner that gives you a quick enumeration of drive and model/serial number:

ls -l /dev/disk/by-id/ | grep scsi- | grep -v part | awk '{print $NF " " $(NF-2)}' | sed 's|../../||g' | sed 's/scsi-...._//g'  

Or for remote machines:

ssh $host "ls -l /dev/disk/by-id/ | grep scsi- | grep -v part | awk '{print \$NF \" \" \$(NF-2)}' | sed 's|../../||g' | sed 's/scsi-...._//g'"

You can then further process this output. For most drive types, the second string per line is MODEL_SERIAL.

share|improve this answer

Like womble said, without root access or granting root-like permissions to some process, you can't achieve this. However, since you say you are a newbie, let me note you about a handy command called lshw.

share|improve this answer
Thank you to both Womble and yourself, very much appreciated. I shall investigate the command you mentioned. –  user92971 Aug 28 '11 at 10:40

Short of granting root-like permissions to some process, you can't achieve this. Even as root you can't do it on some hardware configurations.

share|improve this answer
Thanks for your quick response Womble. I will give it a go. –  mustafa Aug 26 '11 at 10:18

The links under /dev/disk/by-id is created by udev. In /etc/udev/rules.d/50-udev.rules such lines can be found:

KERNEL=="sd*[!0-9]|sr*", SYSFS{ieee1394_id}=="*", ENV{ID_SERIAL}="$sysfs{ieee1394_id}", ENV{ID_BUS}="ieee1394"
KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}=="", IMPORT{program}="/lib/udev/usb_id -x"
KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}=="", IMPORT{program}="/lib/udev/scsi_id -g -x -s %p -d $tempnode"
KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}=="", IMPORT{program}="/lib/udev/scsi_id -g -x -a -s %p -d $tempnode"
KERNEL=="nst[0-9]*|st*|sd*[!0-9]|sr*|dasd*[!0-9]|cciss?c", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/$env{ID_BUS}-$env{ID_SERIAL}"

Unfortunately it is not trivial to find out this by-id symlink from the name of the device. But there is at least one direct way:

$ udevinfo -q path -n /dev/sda
$ udevinfo -q symlink -p /block/sda
disk/by-id/scsi-SATA_KINGSTON_SVP100_31JY100MY5SK disk/by-path/pci-0000:00:11.0-scsi-0:0:0:0

A space separated list is returned. So the by-id path can be found.

Or You can directly get the "composite" serial number:

$ udevinfo -q env -p /block/sda

In the ID_SERIAL after the last underscore You can get the serial number.

As I see a serial number can contain alphanumerical characters and '-' (I have such SCSI HDDs). Does anybody know any limitation about the serial number? It if can contain '_' then this method is not bullet proof.

The ID_MODEL key could be used to localise more precisely the beginning of the serial number, as (it seems to me) its first 15 characters are added to the ID_SERIAL (spaces replaced by '_').

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.