» Generate a moderately secure random password
Just to remind myself...
;)
cat /dev/urandom \ | base64 \ | tr -d '[^:alnum:]' \ | cut -c1-10 \ | head -1The command chain above does the following:
dd if=/dev/urandom
: read random data from/dev/urandom
and write it to STDOUTbase64
: encode that binary data into Base64 to make it human-readabletr -d '[^:alnum:]'
: remove all characters that are not alphanumeric (i.e. remove whitespaces, +, ...)cut -c1-10
: only keep characters 1 to 10 from each linehead -1
: only keep the first line
cat
on /dev/random
instead of /dev/urandom
, if you have enough entropy (see cat /proc/sys/kernel/random/entropy_avail
)
Obviously, if you prefer passwords of a different length, e.g. 16, change the cut -c1-10
accordingly: cut -c1-16