6-digit hexadecimal ID in shell

Hi, i tried to do this script:
Generate a "unique" 6-digit hexadecimal identifier for your computer. Do not use the flawed hostid command. Hint: md5sum /etc/passwd, then select the first 6 digits of output.

Fom 0 to 9 and from a to f

#!/bin/bash
clear
echo ""
echo "--------------------"
echo ""
echo "Unique System ID"
echo ""
echo "Your ID is:: "
md5sum /etc/passwd | cut -c 1-6
echo ""
echo "--------------------"
echo ""

Can someone help me to get it work? because mine isnt totally random, if i run it again it keeps sending me the same id :S

And it won't change until the passwd file does. I agree, this isn't a very random way to get a unique system id, especially since /etc/passwd doesn't contain passwords! Base installs of the same OS will be identical.

dd if=/dev/urandom count=256 bs=1 2>/dev/null | md5sum should be more random.

I must be misunderstanding what you're trying to do. The concept of a unique ID for a computer would seem to be something that would be constant for the life of that piece of hardware and different from any other computer on the planet. Anything based on /etc/passwd fails on both counts. Furthermore, is 16**6 different possible values sufficient for identifying a unique ID in the set of computers?

If you're looking for something unique and constant, you would usually use something like serial #, model #, and manufacturer in toto; not some 6 character subset of that data.

Might not be the right forum for this type of question. And, we're still awaiting an answer to this question.

A unique ID is not a random ID.
Assuming that /etc/hosts is unique on each system I propose this (with a crontab-safe %)

cksum /etc/hosts | awk '{print $1'\%'1000000}'