Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I wanna know that is there's a way, by which we can generate a unique hardware hash of particular machine? The hash should be unique to the machine and hash should be different even two machines are of same configuration. Is it possible?

share|improve this question
What do you need this for? – starblue Jul 24 '11 at 13:41

You could use the MAC address of eth0 (assuming this exists on each machine). You can get that on its own (there may be a simpler way) with this:

ifconfig eth0 | grep HWaddr | awk '{ print $NF}' | sed 's/://g'

That will give you something like 6cf04954aaaa.

These are supposed to be unique but they're not always. If all your network hardware comes from the same manufacturer, you might find some crossover, so be careful with it.

Failing that, you could generate your own unique string and store it in /etc/computer-id (or another path of your choosing).

uuidgen -r

Will generate something as random as possible eg: 52a85807-35fe-409e-8983-87eb58c02ece

uuidgen -t

Uses time and eth0's MAC to make something like: eb8280dc-b5ec-11e0-90dd-6cf04954aaaa

Both are fairly unique but, as with anything random, there is always the possibility of a clash. Keep a central list to avoid problems like this.

share|improve this answer
Although in the case of the randomly-generated UUID, the probability of a clash is so small that it is never going to happen in the foreseeable lifetime of the universe (excepting any major bugs in the random-number implementation). – TooManyKooks Jul 24 '11 at 13:03
@OrbWeaver Well that's the thing about random... It's not sequential. A clash might happen in a hundred years but it might happen the very next run. – Oli Jul 24 '11 at 14:25
Yes, it could happen, but the probability is so low that it is effectively zero for all practical purposes. The entire point of using UUIDs is that they can be generated without a central authoritative list; if you are going to use this anyway you might as well just allocate numbers sequentially from 1. Whether any of this is relevant though depends on the asker's requirements: he might want a hash that is deterministically based on the hardware rather than randomly generated. – TooManyKooks Jul 24 '11 at 16:52

The simplest solution I could think of is:

sudo dmidecode -s system-uuid

According to the manual page of dmidecode, this data is retrieved from the Desktop Management Interface which has something to do with the BIOS. It cannot be changed.

I tested this command on two machines with the same hardware and the result is different as expected from the name system-uuid, so it can actually be used as unique hardware hash.

share|improve this answer
This can be similarly wobbly as MAC addresses on their own. My system-UUID is 00000000-0000-0000-0000-6CF04954AAAA (lots of zeros followed by my MAC address). I'm sure some manufacturers do do this better but Gigabyte seem to be idiots at times. If they did this for all their motherboards, there's only ~17Million combinations and I can all but guarantee they've made more motherboards than that - there will be clashes somewhere. – Oli Jul 24 '11 at 12:16
@Oli: now you mention it, on my system it's like 12345678-ABCD-0000-0000-000000000000 (MAC followed by zeroes). – Lekensteyn Jul 24 '11 at 12:19
You wouldn't have thought generating a 128-bit number (it's not even that, as they get the first two bytes generated for them as their manufacturing ID) wouldn't be too hard... They could have even done it sequentially. Can't believe how lazy some are. – Oli Jul 24 '11 at 12:23
For those who are wondering: changing the MAC address does not affect system-uuid. – Lekensteyn Jul 24 '11 at 12:23
@Oli I did, but that can be changed. Randomness is not an unique hardware hash. – Lekensteyn Jul 24 '11 at 12:26

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.