1 min to read
Random Password Generator
Bash one-liner
Use Bash function (for learning purposes)
#!/bin/bash
# Function to generate a 32 character random password
randomPass() {
#Set local variable for password
local randompass=$(cat /dev/urandom | env LC_CTYPE=C tr -dc 'a-zA-Z0-9!@#$%^&*()_+?><~\`;' | fold -w 32 | head -n 1)
echo $randompass
}
randomPass
Quick one-liner
cat /dev/urandom | env LC_CTYPE=C tr -dc 'a-zA-Z0-9!@#$%^&*()_+?><~\`;' | fold -w 32 | head -n 1