getentropy - Linux


getentropy is a command that provides access to the kernel’s entropy pool. The entropy pool is a source of randomness that is used to generate cryptographic keys and other secure data. getentropy can be used to read random bytes from the pool or to query the current level of entropy.


getentropy [-b BYTES] [-v] [-w] [-n]


  • -b BYTES: Specifies the number of bytes to read from the entropy pool. If this option is not specified, getentropy will read 128 bytes by default.
  • -v: Verbose output. getentropy will print additional information about the entropy pool, including the current entropy level and the number of bytes available.
  • -w: Wait for entropy. getentropy will block until there is enough entropy available in the pool to satisfy the requested number of bytes.
  • -n: No output. getentropy will not print any output.


Read 256 bytes from the entropy pool:

$ getentropy -b 256

Wait for entropy and read 128 bytes:

$ getentropy -w -b 128

Query the current entropy level:

$ getentropy -v

Common Issues

getentropy may block if there is not enough entropy available in the pool. This can happen if the system is not generating enough entropy or if the entropy pool has been depleted. To resolve this issue, you can wait for the system to generate more entropy or you can use the -w option to force getentropy to wait until there is enough entropy available.


getentropy can be used with other Linux commands to generate secure data. For example, you can use getentropy to generate a random password:

$ getentropy -b 32 | tr -dc 'a-zA-Z0-9' | head -c 32

Related Commands

  • rngd: A daemon that generates entropy from various sources.
  • haveged: A hardware-based entropy generator.
  • yarrow: A pseudorandom number generator that uses an entropy pool to generate random numbers.