Skip to content

Instantly share code, notes, and snippets.

@wdzajicek
Last active December 19, 2020 02:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wdzajicek/4b9d5f50af67fa6d3c4ebbf6c4298129 to your computer and use it in GitHub Desktop.
Save wdzajicek/4b9d5f50af67fa6d3c4ebbf6c4298129 to your computer and use it in GitHub Desktop.
Terminal random password generator
# Create a random string of characters that are safe for passwords
## Terminal random password generator
## The "translate characters" (`tr`) command didn't work on my Mac without prepending with `LC_ALL=C`
LC_ALL=C tr -dc 'A-Za-z0-9!"#$%&'\''()*+,-./:;<=>?@[\]^_`{|}~' </dev/urandom | head -c 13 ; echo
## Change the length of the outputed string by adjusting the number at the end of the command: `| head -c 13 ; echo`
## The line of code above will generate a random string that is 13 characters long.
## 16 chars would end with: `| head -c 16 ; echo`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment