6-digit hexadecimal ID in shell


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users 6-digit hexadecimal ID in shell
# 1  
Old 10-20-2014
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

Code:
#!/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
# 2  
Old 10-20-2014
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.
# 3  
Old 10-20-2014
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.
# 4  
Old 10-20-2014
Might not be the right forum for this type of question. And, we're still awaiting an answer to this question.
# 5  
Old 10-20-2014
A unique ID is not a random ID.
Assuming that /etc/hosts is unique on each system I propose this (with a crontab-safe %)
Code:
cksum /etc/hosts | awk '{print $1'\%'1000000}'

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

convert two digit in to single digit...

Hi Guys. My Input: ABCD 12 00 KL ABCD 12 08 DL ABCD 12 10 KK ABCD 12 04 LL ABCD 13 00 LP ABCD 13 1O LS Output: ABCD 12 0 KL ABCD 12 8 DL ABCD 12 10 KK ABCD 12 4 LL ABCD 13 0 LP (2 Replies)
Discussion started by: pareshkp
2 Replies

2. Shell Programming and Scripting

Hexadecimal increment using shell script

I am looking for hexadecimal increment by reading user input using shell script. For example the user input is 01A. I want to increase the hex count by 4 times Looking for output: 01A O1B 01C 01D 01E Can someone suggest? (14 Replies)
Discussion started by: sai_1712
14 Replies

3. Shell Programming and Scripting

awk length of digit and print at most right digit

Have columns with digits and strings like: input.txt 3840 3841 3842 Dav Thun Tax Cahn 146; Dav. 3855 3853 3861 3862 Dav Thun Tax 2780 Karl VI., 3873 3872 3872 Dav Thun Tax 3894 3893 3897 3899 Dav Thun Tax 403; Thun 282. 3958 3959 3960 Dav Thun Tax 3972 3972 3972 3975 Dav Thun Tax... (8 Replies)
Discussion started by: sdf
8 Replies

4. Programming

Hexadecimal to ascii

Let's suppose i have a hexadecimal array with 16 cells.for example b3e2d5f636111780 i want to convert it to an array of ascii characters(in C) so that i can reduce total size of the file i want to put it in. But i am afraid i have not fully understand the difference between ascii and hex(i... (3 Replies)
Discussion started by: bashuser2
3 Replies

5. Shell Programming and Scripting

Single digit date to double digit date.

I have a var storing date var=`date` Now the date is returned as Mon Feb 2 00:25:48 PST 2009 Is there any way to check the date field alone ("2" in above case) and if its a single digit then add a prefix 0 to it and store the result in same variable "var" My intention in above case is... (3 Replies)
Discussion started by: villain41
3 Replies

6. Shell Programming and Scripting

How to convert a 2 digit to 4 digit

Hi All, How can i convert a number 24 to 0024 In the same way how can i convert 123 to 0123? All this has to be done inside a script Thanks in advance JS (6 Replies)
Discussion started by: jisha
6 Replies

7. Shell Programming and Scripting

Replace one digit by two digit using sed

Folks, Is there a simple way to replace one digit by two digit using sed. Example, mydigit1918_2006_8_8_lag1.csv should be mydigit1918_2006_08_08_lag01.csv. I tried this way, but doesn't work. echo mydigit1989_2006_8_8_lag1.csv|sed 's/]/0]/' Thank you, (5 Replies)
Discussion started by: Jae
5 Replies

8. Shell Programming and Scripting

why "expr "${REPLY}" : '\([1-9][[:digit:]]*\)" can figure out whether it is a digit?

I found below script to check whether the variable is a digit in ksh. ############################ #!/bin/ksh REPLY="3f" if ]*\)'` != ${REPLY} && "${REPLY}" != "0" ]] then print "is digit\n" else print "not digit\n" fi ############################ Although it works fine, but... (6 Replies)
Discussion started by: sleepy_11
6 Replies

9. Shell Programming and Scripting

Write a shell program to find the sum of alternate digits in a given 5-digit number

Hi Can any one please post the answer for the above program.................. (4 Replies)
Discussion started by: banta
4 Replies

10. Shell Programming and Scripting

Get Hexadecimal Value

I have a record in a file that ends with the new line character "\n". How dio I determine the hexadecimal value for that? (2 Replies)
Discussion started by: lesstjm
2 Replies
Login or Register to Ask a Question