MCOOKIE(1) User Commands MCOOKIE(1)

# [NAME](#NAME)

mcookie - generate magic cookies for xauth

# [SYNOPSIS](#SYNOPSIS)

**mcookie** \[options]

# [DESCRIPTION](#DESCRIPTION)

**mcookie** generates a 128-bit random hexadecimal number for use with the X authority system. Typical usage:

**xauth add :0 .** mcookie

The "random" number generated is actually the MD5 message digest of random information coming from one of the sources [**getrandom**(2)](/man/os/util-linux/getrandom.2) system call, */dev/urandom*, */dev/random*, or the *libc pseudo-random functions*, in this preference order. See also the option **--file**.

# [OPTIONS](#OPTIONS)

**-f**, **--file** *file*

Use this *file* as an additional source of randomness (for example */dev/urandom*). When *file* is '-', characters are read from standard input.

**-m**, **--max-size** *number*

Read from *file* only this *number* of bytes. This option is meant to be used when reading additional randomness from a file or device.

The *number* argument may be followed by the multiplicative suffixes KiB=1024, MiB=1024\*1024, and so on for GiB, TiB, PiB, EiB, ZiB and YiB (the "iB" is optional, e.g., "K" has the same meaning as "KiB") or the suffixes KB=1000, MB=1000\*1000, and so on for GB, TB, PB, EB, ZB and YB.

**-v**, **--verbose**

Inform where randomness originated, with amount of entropy read from each source.

**-h**, **--help**

Display help text and exit.

**-V**, **--version**

Display version and exit.

# [FILES](#FILES)

*/dev/urandom*

*/dev/random*

# [BUGS](#BUGS)

It is assumed that none of the randomness sources will block.

# [SEE ALSO](#SEE_ALSO)

[**md5sum**(1)](/man/os/util-linux/md5sum.1), [**X**(7)](/man/os/util-linux/X.7), [**xauth**(1)](/man/os/util-linux/xauth.1), [**rand**(3)](/man/os/util-linux/rand.3)

# [REPORTING BUGS](#REPORTING_BUGS)

For bug reports, use the *issue tracker* &lt;https://github.com/util-linux/util-linux/issues&gt;.

# [AVAILABILITY](#AVAILABILITY)

The **mcookie** command is part of the util-linux package which can be downloaded from *Linux Kernel Archive* &lt;https://www.kernel.org/pub/linux/utils/util-linux/&gt;.

2026-09-25 util-linux 2.42.4

---

Document: mcookie(1) from util-linux 2.42.4-r0 (Chainguard OS)
