mcookie(1)

mcookie1

Generate magic cookies for xauth

Usage

mcookie [options]

Overview

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) system call, /dev/urandom, /dev/random, or the libc pseudo-random functions, in this preference order. See also the option --file.

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

/dev/urandom

/dev/random

Releases

18 releases since Debian 1.2 (Rex); the text changed 12 times.

  1. 1.2–1.3
  2. 2.0–2.1
  3. 2.2–4.0
  4. 5.0
  5. 6.0
  6. 7
  7. 8
  8. 9
  9. 10
  10. 11
  11. 12
  12. 13
  13. Arch

--file since Debian 7 (Wheezy); --help since Debian 7 (Wheezy); --max-size since Debian 8 (Jessie); --verbose since Debian 7 (Wheezy); --version since Debian 7 (Wheezy); -V since Debian 7 (Wheezy); -f since Debian 7 (Wheezy); -h since Debian 7 (Wheezy); -m since Debian 8 (Jessie); -v since Debian 7 (Wheezy).

Bugs

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

Reporting bugs

For bug reports, use the issue tracker <https://github.com/util-linux/util-linux/issues>.

Availability

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

From util-linux 2.42.4-1 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.