codrut.pro
  • CV
  • Projects
  • Snippets
  • Tags
  • More

One Liners: Generate random password

July 28, 2020 One-minute read
bash

Basic command:

tr -dc "a-zA-Z0-9" < /dev/urandom | head -c 32

Print it to STDOUT:

echo $(tr -dc "a-zA-Z0-9" < /dev/urandom | head -c 32)

Save it in an environment variable:

export SECRET_PASSWORD=$(tr -dc "a-zA-Z0-9" < /dev/urandom | head -c 32)

See also in One Liners Link to heading

  • One Liners: Edit hosts file