Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

It's obviously good for creating dummy data; also can be used for generating passwords (although I believe you have to be careful here as to the true "randomness"). Any other useful uses that you've come across?

share|improve this question
I think this should go to Super User. At the very least it should be a wiki article. – John Gardeniers Aug 17 '09 at 9:27

It can be used for generating names for temporary files and directories (something like mktemp is even better, but may not always be available).

share|improve this answer
Interesting - I imagine if you're creating a lot of temporary stuff then a random number concatenated to say the date or appname, may be useful. Thx for the input sleske. – DBMarcos99 Aug 17 '09 at 18:37

I'd use it in bash scripts the exact same way you'd use random number generation in other programming languages.

As your comment put it, what if you want to write some data to a file but don't have a good naming scheme? You could just name the file /tmp/data-$RANDOM.txt and since you know what $RANDOM is, you can make note of it in your script and act accordingly.

Or maybe you have multiple programs you've spawned off that need to share some secret data that you know you can safely store unencrypted on the file system. Just generate some random number and use that if they need to chat over a secure line so that they can verify the other programs are legitimate (although you should be very careful with an approach like this, security-wise).

share|improve this answer
$$ is usually used for this instead of $RANDOM - it's more portable and as a bonus, monotonically increasing. – pjz Sep 17 '09 at 22:03

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.