If X is 5, it will about a number between 1 and 5 inclusive. This works in bash and zsh. If you want between 0 and 4, remove the +1.
Do a git commit using a random message. Show Sample Output
/dev/urandom is cryptographically secure, and indistinguishable from true random, as it gathers data from external sources, influenced by human timing interactions with computers, to fill the entropy pool, and hashes the input with SHA-1. As such, this is a quick way to do a "true random" fair-6 dice roll. Using this method, you could easily create passphrases with Diceware http://diceware.com. Change the head(1) count to something other than 5 for more or less numbers.
I used only shuf command. Show Sample Output
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
Silly Perl variant.
You need to have fortune and cowsay installed. It uses a subshell to list cow files in you cow directory (this folder is default for debian based systems, others might use another folder). you can add it to your .bashrc file to have it great you with something interesting every time you start a new session. Show Sample Output
Avoiding a for loop brought this time down to less than 3 seconds on my old machine. And just to be clear, 33554432 = 8192 * 4086.
A bash version.
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.
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
It takes a byte from /dev/random whose source is the kernel entropy pool (better source than other solutions). Show Sample Output
Plays whitenoise from /dev/urandom. Show Sample Output
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
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.
shuf is in the coreutils package
Works in sort (GNU coreutils) 7.4, don't know when it was implemented but sometime the last 6 years.
Prepending env LC_CTYPE=C fixes a problem with bad bytes in /dev/urandom on Mac OS X
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!!!
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.
use it to add a random boolean switch to your script Show Sample Output
Generates password consisting of alphanumeric characters, defaults to 16 characters unless argument given. Show Sample Output
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.
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
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: