uuid

Generate a Universally Unique Identifier (UUID)

http://en.wikipedia.org/wiki/Universally_Unique_Identifier http://www.ossp.org/pkg/lib/uuid/ You'll first need to install the uuid package. Available immediately from apt in Ubuntu, Debian, or other myriad Debian variants. You could always compile it from source as well.
Sample Output
bfcca18a-8857-11de-bdc3-0024e80e2d83

-1
2009-08-14 14:02:37

These Might Interest You

  • piped this to pbcopy (OSX only) you got a uuid in the pasteboard Show Sample Output


    0
    echo "import uuid\nimport sys\nsys.stdout.write(str(uuid.uuid4()))" | python
    tippy · 2014-07-23 07:43:01 1
  • Remove dashes, also validates if it's a valid UUID (in contrast to simple string-replacement)


    -2
    python -c "from uuid import UUID; print UUID('63b726a0-4c59-45e4-af65-bced5d268456').hex;"
    mackaz · 2011-11-20 10:35:44 0
  • first off, if you just want a random UUID, here's the actual command to use: uuidgen Your chances of finding a duplicate after running this nonstop for a year are about the same as being hit by a meteorite before finishing this sentence The reason for the command I have is that it's more provably unique than the one that uuidgen creates. uuidgen creates a random one by default, or an unencrypted one based on time and network address if you give it the -t option. Mine uses the mac address of the ethernet interface, the process id of the caller, and the system time down to nanosecond resolution, which is provably unique over all computers past, present, and future, subject to collisions in the cryptographic hash used, and the uniqueness of your mac address. Warning: feel free to experiment, but be warned that the stdin of the hash is binary data at that point, which may mess up your terminal if you don't pipe it into something. If it does mess up though, just type reset Show Sample Output


    0
    printf $(( echo "obase=16;$(echo $$$(date +%s%N))"|bc; ip link show|sed -n '/eth/ {N; p}'|grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}'|head -c 17 )|tr -d [:space:][:punct:] |sed 's/[[:xdigit:]]\{2\}/\\x&/g')|sha1sum|head -c 32; echo
    camocrazed · 2010-07-14 14:04:53 0
  • Remove the dashes from a UUID using bash search and replace. Show Sample Output


    0
    UUID="63b726a0-4c59-45e4-af65-bced5d268456"; echo ${UUID//-/}
    flatcap · 2011-11-22 22:49:30 5
  • This is based on the Windows Version of VirtualBox. From the /? ... VBoxManage clonehd | [--format VDI|VMDK|VHD|RAW|] [--variant Standard,Fixed,Split2G,Stream,ESX] [--type normal|writethrough|immutable|shareable] [--remember] [--existing] From the online help.. http://www.virtualbox.org/manual/ch08.html#id2676537 VBoxManage clonehd This command duplicates a registered virtual hard disk image to a new image file with a new unique identifier (UUID). The new image can be transferred to another host system or imported into VirtualBox again using the Virtual Media Manager; see the section called ?The Virtual Media Manager? and the section called ?Cloning disk images?. The syntax is as follows: VBoxManage clonehd | [--format VDI|VMDK|VHD|RAW|] [--variant Standard,Fixed,Split2G,Stream,ESX] [--type normal|writethrough|immutable] [--remember] where the parameters mean: format Allow to choose a file format for the output file different from the file format of the input file. variant Allow to choose a file format variant for the output file. It is a comma-separated list of variant flags. Not all combinations are supported, and specifying inconsistent flags will result in an error message. type Only honored if --remember is also specified. Defines what kind of hard disk type this image should be. remember Keep the destination image registered after it was successfully written. Show Sample Output


    -3
    vboxmanage clonehd --format VMDK <source image|uuid> <destination image>
    dreffed · 2010-10-04 16:42:12 0
  • Get out of jail for VMs that won't reboot. Warning: I have no idea why this works or what the implications of the 'destroy_domain' command are but this is how I'm recovering my hung VMs: xe vm-list Locate the UUID of broken VM by name. list_domains Locate ID of broken VM by UUID. destroy_domain -domid <ID> Destroy the domain. xe vm-reboot uuid=<UUID> --force Force a reboot of the VM.


    0
    /opt/xensource/debug/destroy_domain -domid <id>
    rik · 2012-02-23 11:21:49 0

What Others Think

ruby -e 'z = (1..17).map{"%0.2X"%rand(256)}.join.downcase ; uuid = z[1..8] + "-" + z[9..12] + "-" + z[13..16] + "-" + z[17..33]; puts uuid'
azulinho · 281 weeks and 3 days ago
that was wrong, this one should do it: ruby -e 'z = (1..17).map{"%0.2X"%rand(256)}.join.downcase ; uuid = z[1..8] + "-" + z[9..12] + "-" + z[13..16] + "-" + z[17..20] + "-" + z[21..32]; puts uuid'
azulinho · 281 weeks and 3 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: