Jan 15 2014

Linux random password

in bash script
tr -dc A-Za-z0-9_ < /dev/urandom | head -c 16 | xargs

function in $HOME/.bashrc
genpasswd() {
local l=$1
[ "$l" == "" ] && l=16
tr -dc A-Za-z0-9_ < /dev/urandom | head -c ${l} | xargs }

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.