Commands matching random (388)


  • 9
    cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 32
    noqqe · 2011-11-20 17:29:45 3
  • Twitter stream feeds now require authentication. This command is the FIRST in a set of five commands you'll need to get Twitter authorization for your final Twitter command. *** IMPORTANT *** Before you start, you have to get some authorization info for your "app" from Twitter. Carefully follow the instructions below: Go to dev.twitter.com/apps and choose "Create a new application". Fill in the form. You can pick any name for your app. After submitting, click on "Create my access token". Keep the resulting page open, as you'll need information from it below. If you closed the page, or want to get back to it in the future, just go to dev.twitter.com/apps Now customize FIVE THINGS on the command line as follows: 1. Replace the string "Consumer key" by copying & pasting your custom consumer key from the Twitter apps page. 2. Replace the string "Consumer secret" by copying & pasting your consumer secret from the Twitter apps page. 3. Replace the string "Access token" by copying & pasting your access token from the Twitter apps page. 4. Replace string "Access token secret" by copying & pasting your own token secret from the Twitter apps page. 5. Replace the string 19258798 with the Twitter UserID NUMBER (this is **NOT** the normal Twitter NAME of the user you want the tweet feed from. If you don't know the UserID number, head over to www.idfromuser.com and type in the user's regular Twitter name. The site will return their Twitter UserID number to you. 19258798 is the Twitter UserID for commandlinefu, so if you don't change that, you'll receive commandlinefu tweets, uhm... on the commandline :) Congratulations! You're done creating all the keys! Environment variables k1, k2, k3, and k4 now hold the four Twitter keys you will need for your next step. The variables should really have been named better, e.g. "Consumer_key", but in later commands the 256-character limit forced me to use short, unclear names here. Just remember k stands for "key". Again, remember, you can always review your requested Twitter keys at dev.twitter.com/apps. Our command line also creates four additional environment variables that are needed in the oauth process: "once", "ts", "hmac" and "id". "once" is a random number used only once that is part of the oauth procedure. HMAC is the actual key that will be used later for signing the base string. "ts" is a timestamp in the Posix time format. The last variable (id) is the user id number of the Twitter user you want to get feeds from. Note that id is ***NOT*** the twitter name, if you didn't know that, see www.idfromuser.com If you want to learn more about oauth authentication, visit oauth.net and/or go to dev.twitter.com/apps, click on any of your apps and then click on "Oauth tool" Now go look at my next command, i.e. step2, to see what happens next to these eight variables.


    9
    step1() { k1="Consumer key" ; k2="Consumer secret" ; k3="Access token" ; k4="Access token secret" ; once=$RANDOM ; ts=$(date +%s) ; hmac="$k2&$k4" ; id="19258798" ; }
    nixnax · 2012-03-11 20:40:56 3
  • Uses the extremely cool utilities netcat and expect. "expect" logs in & monitors for server PING checks. When a PING is received it sends the PONG needed to stay connected. IRC commands to try: HELP, TIME, MOTD, JOIN and PRIVMSG The "/" in front of IRC commands are not needed, e.g. type JOIN #mygroup Learn about expect: http://tldp.org/LDP/LGNET/issue48/fisher.html The sample output shows snippets from an actual IRC session. Please click UP button if you like it! Show Sample Output


    9
    nik=clf$RANDOM;sr=irc.efnet.org;expect -c "set timeout -1;spawn nc $sr 6666;set send_human {.1 .2 1 .2 1};expect AUTH*\n ;send -h \"user $nik * * :$nik commandlinefu\nnick $nik\n\"; interact -o -re (PING.:)(.*\$) {send \"PONG :\$interact_out(2,string)\"}"
    omap7777 · 2015-03-18 09:10:28 46
  • this string of commands will release your dhcp address, change your mac address, generate a new random hostname and then get a new dhcp lease.


    8
    dhclient -r && rm -f /var/lib/dhcp3/dhclient* && sed "s=$(hostname)=REPLACEME=g" -i /etc/hosts && hostname "$(echo $RANDOM | md5sum | cut -c 1-7 | tr a-z A-Z)" && sed "s=REPLACEME=$(hostname)=g" -i /etc/hosts && macchanger -e eth0 && dhclient
    grokskookum · 2009-09-28 22:07:31 7
  • for Mac OS X Show Sample Output


    8
    openssl rand -base64 6
    gikku · 2009-12-02 10:10:58 12

  • 8
    COL=$(( $(tput cols) / 2 )); clear; tput setaf 2; while :; do tput cup $((RANDOM%COL)) $((RANDOM%COL)); printf "%$((RANDOM%COL))s" $((RANDOM%2)); done
    sputnick · 2009-12-15 02:48:28 10
  • Mask the user agent as firefox, recursively download 2 levels deep from a span host with a maximum of 1 redirection, use random wait time and dump all pdf files to myBooksFolder without creating any other directories. Host will have no way of knowing that this is a grabber script.


    8
    wget -erobots=off --user-agent="Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.3) Gecko/2008092416 Firefox/3.0.3" -H -r -l2 --max-redirect=1 -w 5 --random-wait -PmyBooksFolder -nd --no-parent -A.pdf http://URL
    unixmonkey8504 · 2010-03-01 20:22:44 28
  • A bash version.


    8
    echo $((RANDOM%256)).$((RANDOM%256)).$((RANDOM%256)).$((RANDOM%256))
    putnamhill · 2011-01-16 23:02:01 7
  • bash.org is a collection of funny quotes from IRC. WARNING: some of the quotes contain "adult" jokes... may be embarrassing if your boss sees them... Thanks to Chen for the idea and initial version! This script downloads a page with random quotes, filters the html to retrieve just one liners quotes and outputs the first one. Just barely under the required 255 chars :) Improvment: You can replace the head -1 at the end by: awk 'length($0)>0 {printf( $0 "\n%%\n" )}' > bash_quotes.txt which will separate the quotes with a "%" and place it in the file. and then: strfile bash_quotes.txt which will make the file ready for the fortune command and then you can: fortune bash_quotes.txt which will give you a random quote from those in the downloaded file. I download a file periodically and then use the fortune in .bashrc so I see a funny quote every time I open a terminal. Show Sample Output


    7
    curl -s http://bash.org/?random1|grep -oE "<p class=\"quote\">.*</p>.*</p>"|grep -oE "<p class=\"qt.*?</p>"|sed -e 's/<\/p>/\n/g' -e 's/<p class=\"qt\">//g' -e 's/<p class=\"qt\">//g'|perl -ne 'use HTML::Entities;print decode_entities($_),"\n"'|head -1
    Iftah · 2009-05-07 13:13:21 17
  • Next time you are leaching off of someone else's wifi use this command before you start your bittorrent ...for legitimate files only of course. It creates a hexidecimal string using md5sum from the first few lines of /dev/urandom and splices it into the proper MAC address format. Then it changes your MAC and resets your wireless (wlan0:0). Show Sample Output


    7
    ran=$(head /dev/urandom | md5sum); MAC=00:07:${ran:0:2}:${ran:3:2}:${ran:5:2}:${ran:7:2}; sudo ifconfig wlan0 down hw ether $MAC; sudo ifconfig wlan0 up; echo ifconfig wlan0:0
    workingsmart · 2009-07-16 16:21:44 5

  • 7
    wget randomfunfacts.com -O - 2>/dev/null|grep \<strong\>|sed "s;^.*<i>\(.*\)</i>.*$;\1;"|cowsay -f tux
    unixmonkey10612 · 2010-07-01 18:31:36 3
  • works at least in bash. returns integer in range 0-32767. range is not as good, but for lots of cases it's good enough.


    7
    echo $RANDOM
    depesz · 2010-11-09 09:57:44 5
  • Seeing that we get back plain text anyway we don't need lynx. Also the sed-part removes the credit line.


    7
    wget -qO - http://www.commandlinefu.com/commands/random/plaintext | sed -n '1d; /./p'
    dramaturg · 2010-12-05 15:32:14 11

  • 7
    curl -s "http://www.gravatar.com/avatar/`uuidgen | md5sum | awk '{print $1}'`?s=64&d=identicon&r=PG" | display
    kev · 2011-11-29 16:41:04 32
  • Generates a TV noise alike output in the terminal. Can be combined with https://www.commandlinefu.com/commands/view/9728/make-some-powerful-pink-noise


    7
    while true;do printf "$(awk -v c="$(tput cols)" -v s="$RANDOM" 'BEGIN{srand(s);while(--c>=0){printf("\xe2\x96\\%s",sprintf("%o",150+int(10*rand())));}}')";done
    ichbins · 2020-05-08 09:55:36 208

  • 7
    tr -dc A-Za-z0-9_ < /dev/urandom | head -c 10 | xargs
    nottings · 2012-10-17 14:04:14 9
  • 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
  • i sorta stole this from http://www.shell-fu.org/lister.php?id=878#MTC_form but it didn't work, so here it is, fixed. --- updated to work with jpegs, and to use a fancy positive look behind assertion.


    6
    display "$(wget -q http://dynamic.xkcd.com/comic/random/ -O - | grep -Po '(?<=")http://imgs.xkcd.com/comics/[^"]+(png|jpg)')"
    grokskookum · 2009-09-14 18:40:14 5
  • Saves to a PDF with title and alt text of comic. As asked for on http://bbs.archlinux.org/viewtopic.php?id=91100 Change xkcd.com to dynamic.xkcd.com/comics/random for a random comic.


    6
    curl -sL xkcd.com | grep '<img [^>]*/><br/>' | sed -r 's|<img src="(.*)" title="(.*)" alt="(.*)" /><br/>|\1\t\2\t\3|' > /tmp/a; curl -s $(cat /tmp/a | cut -f1) | convert - -gravity south -draw "text 0,0 \"$(cat /tmp/a | cut -f2)\"" pdf:- > xkcd.pdf
    matthewbauer · 2010-03-03 03:41:31 14
  • 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
  • This command will show an random command. this is useful if you want to explore various random commands.


    6
    ls /usr/bin | shuf -n 1
    pebkac · 2011-01-07 22:09:12 5

  • 6
    echo "You can have a bit more realistic typing with some shell magic." | pv -qL $[10+(-2 + RANDOM%5)]
    nkoehring · 2011-02-16 01:40:35 8
  • 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
  • you may want &hl=en for &hl=es for the language you may want imgsz=xxlarge for imgsz=large or whatever filter you may want q=apples or whatever


    6
    for i in {1..10};do wget $(wget -O- -U "" "http://images.google.com/images?imgsz=xxlarge&hl=en&q=wallpaper+HD&start=$(($RANDOM%900+100))" --quiet | grep -oe 'http://[^"]*\.jpg' | head -1);done
    dzup · 2012-07-26 10:42:13 6
  •  < 1 2 3 4 >  Last ›

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

count how many cat processes are running

this toggles mute on the Master channel of an alsa soundcard

Delete leading whitespace from the start of each line

Rename all images in current directory to filename based on year, month, day and time based on exif information

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

Password Generation
Produces secure passwords that satisfy most rules for secure passwords and can be customized for correct output as needed. See "man pwgen" for details.

clear current line

Print out a man page
man -t manpagename gives a postscript version of said man page. You then pipe it to ls, and assuming you have cups set up, it prints in your default printer.

Fetch the requested virtual domains and their hits from log file
The command will read the apache log file and fetch the virtual host requested and the number of requests.

Netstat Connection Check
This command does a tally of concurrent active connections from single IPs and prints out those IPs that have the most active concurrent connections. VERY useful in determining the source of a DoS or DDoS attack.


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: