uuidgen 命令详解

| 选择喜欢的代码风格  

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

uuidgen 命令安装:


-bash/zsh: uuidgen: command not found

# Windows (WSL2)
sudo apt-get update sudo apt-get install uuid-runtime

# Debian
apt-get install uuid-runtime

# Ubuntu
apt-get install uuid-runtime

# Alpine
apk add util-linux

# Arch Linux
pacman -S util-linux

# Kali Linux
apt-get install uuid-runtime

# CentOS
yum install util-linux

# Fedora
dnf install util-linux

# OS X
brew install e2fsprogs

# Raspbian
apt-get install uuid-runtime

# Dockerfile
dockerfile.run/uuidgen

# Docker
docker run cmd.cat/uuidgen uuidgen

uuidgen 命令补充说明:


uuidgen 命令创建一个新的通用唯一的使用 libuuid(3) 库的标识符 UUID

uuidgen 可以生成 3 种类型的 UUID

  • 基于时间的 UUID
  • 基于随机的 UUID
  • 基于哈希的 UUID

可以强制使用以下方法生成前两种 UUID 类型: --random--time 选项。

uuidgen 命令语法:


uuidgen [options]

uuidgen 命令选项:


-r, --random
   Generate a random-based UUID. This method creates a UUID
   consisting mostly of random bits. It requires that the
   operating system has a high quality random number generator,
   such as /dev/random.

-t, --time
   Generate a time-based UUID. This method creates a UUID based
   on the system clock plus the system’s ethernet hardware
   address, if present.

-h, --help
   Display help text and exit.

-V, --version
   Print version and exit.

-m, --md5
   Use MD5 as the hash algorithm.

-s, --sha1
   Use SHA1 as the hash algorithm.

-n, --namespace namespace
   Generate the hash with the namespace prefix. The namespace is
   UUID, or '@ns' where "ns" is well-known predefined UUID
   addressed by namespace name (see above).

-N, --name name
   Generate the hash of the name.

-x, --hex
   Interpret name name as a hexadecimal string.

uuidgen 命令实例:


uuidgen 创建随机 UUIDv4

uuidgen --random

uuidgen 根据当前时间创建 UUIDv1

uuidgen --time

uuidgen 创建具有指定命名空间前缀的名称的 UUIDv5

uuidgen --sha1 --namespace @dns|@url|@oid|@x500 --name object_name

uuidgen 命令扩展阅读:




uuidgen 命令评论