Commands matching random password (64)

  • Find random strings within /dev/urandom. Using grep filter to just Alphanumeric characters, and then print the first 30 and remove all the line feeds. Show Sample Output


    54
    strings /dev/urandom | grep -o '[[:alnum:]]' | head -n 30 | tr -d '\n'; echo
    jbcurtis · 2009-02-16 00:39:28 27
  • 4 random words are better than one obfuscated word http://xkcd.com/936/ Show Sample Output


    23
    shuf -n4 /usr/share/dict/words | tr -d '\n'
    Strawp · 2011-08-10 13:04:39 23
  • -B flag = don't include characters that can be confused for other characters (this helps when you give someone their password for the first time so they don't cause a lockout with, for example, denyhosts or fail2ban) -s flag = make a "secure", or hard-to-crack password -y flag = include special characters (not used in the example because so many people hate it -- however I recommend it) "1 10" = output 1 password, make it 10 characters in length For even more secure passwords please use the -y flag to include special characters like so: pwgen -Bsy 10 1 output>> }&^Y?.>7Wu Show Sample Output


    15
    pwgen -Bs 10 1
    linuxrawkstar · 2009-12-01 14:33:51 13
  • If you want a password length longer than 6, changing the -c6 to read -c8 will give you 8 random characters instead of 6. To end up with a line-feed, use this with echo: # echo `< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c6` Modern systems need higher strenght, so add some special characters: # < /dev/urandom tr -dc '12345!@#$%qwertQWERTasdfgASDFGzxcvbZXCVB' | head -c8


    11
    < /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c6
    dstiller · 2009-02-24 09:43:40 13
  • According to the gpg(1) manual: --gen-random 0|1|2 count Emit count random bytes of the given quality level 0, 1 or 2. If count is not given or zero, an endless sequence of random bytes will be emitted. If used with --armor the output will be base64 encoded. PLEASE, don't use this command unless you know what you are doing; it may remove precious entropy from the system! If your entropy pool is critical for various operations on your system, then using this command is not recommended to generate a secure password. With that said, regenerating entropy is as simple as: du -s / This is a quick way to generate a strong, base64 encoded, secure password of arbitrary length, using your entropy pool (example above shows a 30-character long password). Show Sample Output


    11
    gpg --gen-random --armor 1 30
    atoponce · 2011-07-20 15:32:49 8

  • 9
    cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 32
    noqqe · 2011-11-20 17:29:45 3
  • for Mac OS X Show Sample Output


    8
    openssl rand -base64 6
    gikku · 2009-12-02 10:10:58 12
  • See: "man pwgen" for full details. Some Linux distros may not have pwgen included in the base distribution so you maye have to install it (eg in Mandriva Linux: "urpmi pwgen"). Show Sample Output


    6
    pwgen
    mpb · 2009-03-28 11:43:21 5
  • Don't copy trailing '=' or use head -c to limit to desired length. Show Sample Output


    6
    openssl rand -base64 <length>
    buzzy · 2010-05-01 13:09:42 3
  • Generates a random 8-character password that can be typed using only the left hand on a QWERTY keyboard. Useful to avoid taking your hand off of the mouse, especially if your username is left-handed. Change the 8 to your length of choice, add or remove characters from the list based on your preferences or kezboard layout, etc.


    6
    </dev/urandom tr -dc '12345!@#$%qwertQWERTasdfgASDFGzxcvbZXCVB' | head -c8; echo ""
    TexasDex · 2010-06-17 19:30:36 3
  • The pwgen program generates passwords which are designed to be easily memorized by humans, while being as secure as possible. Human-memorable passwords are never going to be as secure as completely completely random passwords. [from pwgen man page] Show Sample Output


    6
    pwgen 30 1
    sairon · 2011-07-24 19:43:48 5
  • This is just a proof of concept: A FILE WHICH CAN AUTOMOUNT ITSELF through a SIMPLY ENCODED script. It takes advantage of the OFFSET option of mount, and uses it as a password (see that 9191? just change it to something similar, around 9k). It works fine, mounts, gets modified, updated, and can be moved by just copying it. USAGE: SEE SAMPLE OUTPUT The file is composed of three parts: a) The legible script (about 242 bytes) b) A random text fill to reach the OFFSET size (equals PASSWORD minus 242) c) The actual filesystem Logically, (a)+(b) = PASSWORD, that means OFFSET, and mount uses that option. PLEASE NOTE: THIS IS NOT AN ENCRYPTED FILESYSTEM. To improve it, it can be mounted with a better encryption script and used with encfs or cryptfs. The idea was just to test the concept... with one line :) It applies the original idea of http://www.commandlinefu.com/commands/view/7382/command-for-john-cons for encrypting the file. The embedded bash script can be grown, of course, and the offset recalculation goes fine. I have my own version with bash --init-file to startup a bashrc with a well-defined environment, aliases, variables. Show Sample Output


    6
    dd if=/dev/zero of=T bs=1024 count=10240;mkfs.ext3 -q T;E=$(echo 'read O;mount -o loop,offset=$O F /mnt;'|base64|tr -d '\n');echo "E=\$(echo $E|base64 -d);eval \$E;exit;">F;cat <(dd if=/dev/zero bs=$(echo 9191-$(stat -c%s F)|bc) count=1) <(cat T;rm T)>>F
    rodolfoap · 2013-01-31 01:38:30 13
  • These are my favourite switches on pwgen: -B Don't include ambiguous characters in the password -n Include at least one number in the password -y Include at least one special symbol in the password -c Include at least one capital letter in the password It just works! Add a number to set password length, add another to set how many password to output. Example: pwgen -Bnyc 12 20 this will output 20 password of 12 chars length. Show Sample Output


    5
    pwgen -Bnyc
    KoRoVaMiLK · 2012-03-15 14:38:15 4
  • Prepending env LC_CTYPE=C fixes a problem with bad bytes in /dev/urandom on Mac OS X


    4
    env LC_CTYPE=C tr -dc "a-zA-Z0-9-_\$\?" < /dev/urandom | head -c 10
    aerickson · 2011-02-22 17:09:44 7
  • Generates password consisting of alphanumeric characters, defaults to 16 characters unless argument given. Show Sample Output


    3
    randpw(){ < /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-16};echo;}
    frozenfire · 2009-08-07 07:30:57 7

  • 3
    date +%s | sha256sum | base64 | head -c <length>; echo
    markdrago · 2010-04-30 22:05:11 7
  • Another password maker, for human-unfriendly passwords. '-base64' output will make sure it it can be typed on a keyboard, though the output string length will always be a multiple of 4. Show Sample Output


    3
    openssl rand -base64 12
    Mozai · 2011-07-06 17:48:26 13
  • This was useful to generate random passwords to some webpage users, using the sample code, inside a bash script Show Sample Output


    2
    echo -n $mypass | md5sum | awk {'print $1'}
    tororebelde · 2009-03-10 13:12:21 4
  • Feel free to put this in your ~/.profile: random(){ cat /dev/urandom | env LC_CTYPE=C tr -dc $1 | head -c $2; echo; } Then use it to generate passwords: random [:alnum:] 16 Or DNA sequences: random ACGT 256


    2
    cat /dev/urandom | env LC_CTYPE=C tr -dc a-zA-Z0-9 | head -c 16; echo
    yakovlev · 2014-02-05 15:04:07 6
  • This command is similar to the alternate, except with head(1), you can pick as many passwords as you wish to generate by changing the number of lines you wish to preview. Show Sample Output


    2
    strings /dev/urandom | tr -cd '[:alnum:]' | fold -w 30 | head -n 1
    atoponce · 2014-12-11 06:21:51 9
  • shell generate random strong password Show Sample Output


    2
    len=20; tr -dc A-Za-z0-9_ < /dev/urandom | head -c ${len} | xargs
    aysadk · 2019-04-16 20:20:46 38
  • make password randomly, default 8 chars, using bash3.X only, no external program.


    1
    genpass(){local i x y z h;h=${1:-8};x=({a..z} {A..Z} {0..9});for ((i=0;i<$h;i++));do y=${x[$((RANDOM%${#x[@]}))]};z=$z$y;done;echo $z ;}
    twfcc · 2009-10-24 04:32:31 13
  • generate password Show Sample Output


    1
    cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 10 | sed 1q
    gnuyoga · 2009-12-01 09:09:56 6
  • Of course you will have to install Digest::SHA and perl before this will work :) Maximum length is 43 for SHA256. If you need more, use SHA512 or the hexadecimal form: sha256_hex() Show Sample Output


    1
    perl -MDigest::SHA -e 'print substr( Digest::SHA::sha256_base64( time() ), 0, $ARGV[0] ) . "\n"' <length>
    udog · 2010-04-30 21:45:46 3

  • 1
    tr -cd '[:alnum:]' < /dev/urandom | fold -w30 | head -n1
    putnamhill · 2010-09-28 12:25:58 5
  •  1 2 3 > 

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands


Check These Out

Find all active ip's in a subnet
nmap for windows and other platforms is available on developer's site: http://nmap.org/download.html nmap is robust tool with many options and has various output modes - is the best (imho) tool out there.. from nmap 5.21 man page: -oN/-oX/-oS/-oG : Output scan in normal, XML, s|

Run command from another user and return to current

Find usb device in realtime
Using this command you can track a moment when usb device was attached.

list block devices
Shows all block devices in a tree with descruptions of what they are.

Check to make sure the whois nameservers match the nameserver records from the nameservers themselves
Change the $domain variable to whichever domain you wish to query. Works with the majority of whois info; for some that won't, you may have to compromise: domain=google.com; for a in $(whois $domain | grep "Domain servers in listed order:" --after 3 | grep -v "Domain servers in listed order:"); do echo ">>> Nameservers for $domain from $a

Create strong, but easy to remember password
Why remember? Generate! Up to 48 chars, works on any unix-like system (NB: BSD use md5 instead of md5sum)

Last month
Work out last months value

Move all but the newest 100 emails to a gzipped archive

Repeatedly send a string to stdout-- useful for going through "yes I agree" screens

kill all process that belongs to you
This will probably kill any user sessions and/or ssh connections to other servers you might have active.


Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: