Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Articles

generate random passwords with a bash function

This article shows you how to create Random passwords in the command line bash by adding a simple function to your bash.rc

as first we need to add this code to our .bash.rc

# Generate a random password
# $1 = number of characters; defaults to 32
# $2 = include special characters; 1 = yes, 0 = no; defaults to 1
function randpass() {
 [ "$2" == "0" ] && CHAR="[:alnum:]" || CHAR="[:graph:]"
 cat /dev/urandom | tr -cd "$CHAR" | head -c ${1:-32}
 echo
}

Once you stored it and read into memory you will be able to generate pw like this:

# randpass 16 0
MkyzmsLYJVIom8B9
# randpass 32 1
g&^>K1:40Y*&R$C(o;q!XS1,2j^_WvRr

enjoy!

get May 08 2022 93 reads 0 comments 1 rating Print

0 comments

Leave a Comment

Please Login to Post a Comment.
  • No Comments have been Posted.


Rating is available to Members only.
Please Login or Register to vote.
Awesome! (1)100 %
Very Good (0)0 %
Good (0)0 %
Average (0)0 %
Poor (0)0 %
Sign In
Not a member yet? Click here to register.
Forgot Password?