Commands matching random (388)

  • 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
  • It takes a byte from /dev/random whose source is the kernel entropy pool (better source than other solutions). Show Sample Output


    6
    od -An -N1 -tu1 /dev/random
    sucotronic · 2013-09-10 08:57:16 123
  • The Speak & Spell's sound chip uses a compressed audio format called "linear predictive coding". This command will read random bytes and attempt to decompress them as if it were audio data compressed in this format, then play it. This results in a unique sound which is similar to a glitching Speak & Spell.


    6
    play -tlpc /dev/urandom
    Sparkette · 2023-02-16 22:28:16 547
  • Same as the cool matrix style command ( http://www.commandlinefu.com/commands/view/3652/matrix-style ), except replacing the printed character with randomness. The command mentioned is much faster and thus more true to the matrix. However, mine can be optimized, but I wasted ... i mean spent enough time on it already Show Sample Output


    6
    check the sample output below, the command was too long :(
    pykler · 2009-09-29 19:30:10 135
  • Pick a mp3 at random and play it. Assumes the availability of locate with an updated db and mpg123 Not the most useful command I guess, but all of the really useful ones are taken...


    5
    mpg123 "`locate -r '\.mp3$'|awk '{a[NR]=$0}END{print a['"$RANDOM"' % NR]}'`"
    unixmonkey1730 · 2009-02-23 13:53:12 13
  • This will generate 3 paragraphs with random text. Change the 3 to any number. Show Sample Output


    5
    lynx -source http://www.lipsum.com/feed/xml?amount=3|perl -p -i -e 's/\n/\n\n/g'|sed -n '/<lipsum>/,/<\/lipsum>/p'|sed -e 's/<[^>]*>//g'
    houghi · 2010-04-26 17:26:44 5

  • 5
    jot -r -n 8 0 9 | rs -g 0
    curiousstranger · 2009-08-22 19:31:17 6
  • A bit different from some of the other submissions. Has bold and uses all c printable characters. Change the bs=value to speed up and increase the sizes of the bold and non-bold strings.


    5
    echo -ne "\e[32m" ; while true ; do echo -ne "\e[$(($RANDOM % 2 + 1))m" ; tr -c "[:print:]" " " < /dev/urandom | dd count=1 bs=50 2> /dev/null ; done
    psykotron · 2009-12-19 19:05:04 4
  • Just after you type enter, you have 3 seconds to switch window, then "texthere" will be "typed" in the X11 application that has focus. Very useful to beat your score at games such as "How fast can you type A-Z".


    5
    sleep 3 && xdotool type --delay 0ms texthere
    drinkcat · 2010-02-18 11:44:18 20
  • the block of the loop is useful whenever you have huge junks of similar jobs, e.g., convert high res images to thumbnails, and make usage out of all the SMP power on your compute box without flooding the system. note: c is used as counter and the random sleep r=`echo $RANDOM%5 |bc`; echo "sleep $r"; sleep $r is just used as a dummy command. Show Sample Output


    5
    c=0; n=8; while true; do r=`echo $RANDOM%5 |bc`; echo "sleep $r"; sleep $r& 2>&1 >/dev/null && ((c++)); [ `echo "$c%$n" | bc` -eq 0 ] && echo "$c waiting" && wait; done
    cp · 2010-07-08 13:56:28 6
  • 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

  • 5
    paste <(seq 7 | shuf | tr 1-7 A-G) <(seq 7 | shuf) | while read i j; do play -qn synth 1 pluck $i synth 1 pluck mix $2; done
    kev · 2012-04-09 15:22:19 3
  • Randomly decide whether to run a command, or fail. It's useful for testing purposes. . Usage: ran PERCENTAGE COMMAND [ARGS] Note: In this version the percentage is required. . This is like @sesom42 and @snipertyler's commands but in a USABLE form. . e.g. In your complicated shell script, put "ran 99" before a crucial component. Now, it will fail 1% of the time allowing you to test the failure code-path. ran 99 my_complex_program arg1 arg2 Show Sample Output


    5
    ran() { [ $((RANDOM%100)) -lt "$1" ] && shift && "$@"; }
    flatcap · 2015-07-16 13:32:45 27
  • Reads psuedorandom bytes from /dev/urandom, filtering out non-printable ones. Other character classes can be used, such as [:alpha:], [:digit:] and [:alnum:]. To get a string of 10 lowercase letters: tr -dc '[:lower:]' < /dev/urandom | head -c 10


    4
    tr -dc '[:print:]' < /dev/urandom
    gracenotes · 2009-02-05 21:51:14 18
  • This appends a random number as a first filed of all lines in SOMEFILE then sorts by the first column and finally cuts of the random numbers.


    4
    awk 'BEGIN{srand()}{print rand(),$0}' SOMEFILE | sort -n | cut -d ' ' -f2-
    axelabs · 2009-05-29 01:20:50 11
  • Figures out total line contribution per author for an entire GIT repo. Includes binary files, which kind of mess up the true count. If crashes or takes too long, mess with the ls-file option at the start: git ls-files -x "*pdf" -x "*psd" -x "*tif" to remove really random binary files git ls-files "*.py" "*.html" "*.css" to only include specific file types Based off my original SVN version: http://www.commandlinefu.com/commands/view/2787/prints-total-line-count-contribution-per-user-for-an-svn-repository Show Sample Output


    4
    git ls-files | xargs -n1 -d'\n' -i git-blame {} | perl -n -e '/\s\((.*?)\s[0-9]{4}/ && print "$1\n"' | sort -f | uniq -c -w3 | sort -r
    askedrelic · 2009-10-25 01:44:03 11

  • 4
    mpg123 `curl -s http://blip.fm/all | sed -e 's#"#\n#g' | grep mp3$ | xargs`
    torrid · 2009-11-07 14:48:01 7
  • Can be integrated into your .bashrc if you like. You'll probably want to grep out my name. Show Sample Output


    4
    lynx --dump http://www.commandlinefu.com/commands/random/plaintext | grep .
    root · 2010-12-04 20:53:10 5
  • 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
  • Prints 0's and 1's in The Matrix style. You can easily modify to print 0-9 digits using $RANDOM %10 insted of %2.


    4
    echo -e "\e[32m"; while :; do printf '%*c' $(($RANDOM % 30)) $(($RANDOM % 2)); done
    fernandomerces · 2012-09-25 17:36:25 4
  • This will parse a random command json entry from http://commandlinefu.com A must have in your .bash_profile to learn new shell goodies at login!!!


    4
    echo -e "`curl -sL http://www.commandlinefu.com/commands/random/json|sed -re 's/.*,"command":"(.*)","summary":"([^"]+).*/\\x1b[1;32m\2\\n\\n\\x1b[1;33m\1\\x1b[0m/g'`\n"
    xenomuta · 2012-08-17 11:47:20 15
  • The output will show jerk, then wonderful person since echo parses the \b character. Show Sample Output


    4
    echo -e "You are a jerk\b\b\b\bwonderful person" | pv -qL $[10+(-2 + RANDOM%5)]
    joeheyming · 2013-01-09 19:18:07 9
  • use it to add a random boolean switch to your script Show Sample Output


    4
    echo $[RANDOM % 2]
    anapsix · 2013-05-25 19:15:57 9
  • don't bother spawning a bc process or counting the number of options, just pick a random one. 'sort -R' sorts randomly, so pick the top one.


    4
    cd ~/wallpapers; feh --bg-fill "$( ls | sort -R | head -n 1 )"
    minnmass · 2014-01-09 03:40:15 7
  • This command generates a pseudo-random data stream using aes-256-ctr with a seed set by /dev/urandom. Redirect to a block device for secure data scrambling.


    4
    openssl enc -aes-256-ctr -pass pass:"$(dd if=/dev/urandom bs=128 count=1 2>/dev/null | base64)" -nosalt < /dev/zero > randomfile.bin
    malathion · 2014-06-02 18:12:54 8
  •  < 1 2 3 4 5 >  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

Prepare a commandlinefu command.
This command will format your alias or function to a single line, trimming duplicate white space and newlines and inserting delimiter semi-colons, so it continues to work on a single line.

Stop Flash from tracking everything you do.
Brute force way to block all LSO cookies on a Linux system with the non-free Flash browser plugin. Works just fine for my needs. Enjoy.

Enter parameter if empty (script becomes interactive when parameters are missing)
Can be used for command line parameters too. If you have a more complicated way of entering values (validation, GUI, ...), then write a function i.e. EnterValue() that echoes the value and then you can write: $ param=${param:-$(EnterValue)}

Change user within ssh session retaining the current MIT cookie for X-forwarding
When you remotely log in like "ssh -X userA:host" and become a different user with "su UserB", X-forwarding will not work anymore since /home/UserB/.Xauthority does not exist. This will use UserA's information stored in .Xauthority for UserB to enable X-forwarding. Watch http://prefetch.net/blog/index.php/2008/04/05/respect-my-xauthority/ for details.

Cut out a piece of film from a file. Choose an arbitrary length and starting time.
With: -vcodec, you choose what video codec the new file should be encoded with. Run ffmpeg -formats E to list all available video and audio encoders and file formats. copy, you choose the video encoder that just copies the file. -acodec, you choose what audio codec the new file should be encoded with. copy, you choose the audio encoder that just copies the file. -i originalfile, you provide the filename of the original file to ffmpeg -ss 00:01:30, you choose the starting time on the original file in this case 1 min and 30 seconds into the film -t 0:0:20, you choose the length of the new film newfile, you choose the name of the file created. Here is more information of how to use ffmpeg: http://www.ffmpeg.org/ffmpeg-doc.html

Validating a file with checksum
Makes sure the contents of "myfile" are the same contents that the author intended given the author's md5 hash of that file ("c84fa6b830e38ee8a551df61172d53d7").

find files ignoring .svn and its decendents

list files recursively by size

Query wikipedia over DNS

Network Discover in a one liner


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: