4 ms·
Little known feature on Linux: cat /proc/sys/kernel/random/uuid
by isp 6y ago
Little known feature on Linux:
cat /proc/sys/kernel/random/uuid
- moviuro 6y agoAlso: uuid -r See https://linux.die.net/man/1/uuid https://linux.die.net/man/1/uuid
- war1025 6y agoWhat's the -r do? Output as raw bytes? I always just do `uuid -v4`
- moviuro 6y ago-r is for "random". I've needed it for one of my scripts: if you generate many UUIDs at once on the same machine, there will be duplicates.
- war1025 6y agoI believe v4 is what you actually want [1]. By default it looks like `uuid` generates a v1 id, which as you said will produce duplicates if you call it too quickly. Maybe your tool is different from the one installed on my machine because when I use the `-r` option I just get garbage back. This leads me to believe it's returning the uuid as raw bytes when I pass that option. $ uuid 97af2898-cb54-11ea-8d75-176c10241ffd $ uuid -v4 0b8d75f5-a148-466c-b1b5-9d9d1022c327 $ uuid -r ����T�����. [1] https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_4_(random) https://en.wikipedia.org/wiki/Universally_unique_identifier#...
- moviuro 6y agoI checked in my code, I actually used `uuidgen`, not `uuid`. Thus the mixup!
- p4l4g4 6y agoAwesome, thanks! I will read up on that! Wonder if it's as stable as using dedicated uuid programs or libraries.