# phpman > man > mcookie(1)

> **TLDR:** Generate random 128-bit hexadecimal numbers.
>
- Generate a random number:
  `mcookie`
- Generate a random number, using the contents of a file as a seed for the randomness:
  `mcookie {{-f|--file}} {{path/to/file}}`
- Generate a random number, using a specific number of bytes from a file as a seed for the randomness:
  `mcookie {{-f|--file}} {{path/to/file}} {{-m|--max-size}} {{number_of_bytes}}`
- Print the details of the randomness used, such as the origin and seed for each source:
  `mcookie {{-v|--verbose}}`

*Source: tldr-pages*

---

[MCOOKIE(1)](https://www.chedong.com/phpMan.php/man/MCOOKIE/1/markdown)                                  User Commands                                 [MCOOKIE(1)](https://www.chedong.com/phpMan.php/man/MCOOKIE/1/markdown)



## NAME
       mcookie - generate magic cookies for xauth

## SYNOPSIS
       **mcookie** [options]

## 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)](https://www.chedong.com/phpMan.php/man/getrandom/2/markdown) system call, _/dev/urandom_, _/dev/random_, or the _libc_
       _pseudo-random_ _functions_, in this preference order. See also the option **--file**.

## OPTIONS
### -f --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
           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.

### -V --version
           Display version information and exit.

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

## FILES
       _/dev/urandom_

       _/dev/random_

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

## SEE ALSO
       [**md5sum**(1)](https://www.chedong.com/phpMan.php/man/md5sum/1/markdown), [**X**(7)](https://www.chedong.com/phpMan.php/man/X/7/markdown), [**xauth**(1)](https://www.chedong.com/phpMan.php/man/xauth/1/markdown), [**rand**(3)](https://www.chedong.com/phpMan.php/man/rand/3/markdown)

## REPORTING BUGS
       For bug reports, use the issue tracker at <https://github.com/karelzak/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/>>.



util-linux 2.37.2                            2021-06-02                                   [MCOOKIE(1)](https://www.chedong.com/phpMan.php/man/MCOOKIE/1/markdown)
