UNIX random devices and utilities

learn more… | top users | synonyms

13
votes
2answers
227 views

What program(s) is(are) lowering my entropy pool level? [duplicate]

I've made a simple bash script that checks the entropy pool level in /dev/random. I realize that the way I do it, I lower it very slightly at each check (cat /proc/sys/kernel/random/entropy_avail) but ...
11
votes
2answers
3k views

What keeps draining entropy?

If I do watch cat /proc/sys/kernel/random/entropy_avail I see that my systems entropy slowly increases over time, until it reaches the 180-190 range at which point it drops down to around 120-130. The ...
5
votes
1answer
65 views

Random image generator

I am generating random data and trying to convert it to a PNG image using : head -c 1MB < /dev/urandom | hexdump -e '16/1 "_x%02X"' | sed 's/_/\\/g; s/\\x //g; s/.*/ "&"/' | tr -d "\"" | ...
28
votes
2answers
22k views

How can I populate a file with random data?

How can I create a new file and fill it with 1 Gigabyte worth of random data? I need this to test some software. I would prefer to use /dev/random or /dev/urandom.
3
votes
1answer
184 views

How to check if reading from /dev/random will block

I have found information that /proc/sys/kernel//random/entropy_avail indicates number of bits available in /dev/random. I wanted to check whether the next reading from /dev/random will block and my ...
0
votes
1answer
56 views

How does this equation gives numbers random between two values?

How does this equation gives random numbers between max and min divisible by divisibleBy echo $(((RANDOM%(max-min+divisibleBy))/divisibleBy*divisibleBy+min))
0
votes
1answer
17 views

KSH password generator

How to make sure the generated passwords contains all these special characters: ?!/=\? Currently I'm using: pwd_usr["$i"]=`cat /dev/urandom|tr -dc "a-zA-Z0-9-_\?\!\=\/\"|fold -w 15|head -n 1` But ...
2
votes
1answer
38 views

Split text file in random halves based on category

I have a text file that looks like this: n03250847/n03250847_0.JPEG n03250847 n03250847/n03250847_1.JPEG n03250847 ... n03250847/n03250847_499.JPEG n03250847 ... n03255030/n03255030_0.JPEG n03255030 ...
1
vote
1answer
58 views

Extract random sample of N lines based on pattern

I have a file formatted like this: train/t/temple/east_asia/00000025.jpg 94 train/t/temple/east_asia/00000865.jpg 94 ... train/s/swamp/00000560.jpg 92 train/s/swamp/00000935.jpg 92 .... train/m/...
0
votes
2answers
43 views

How to pick a random element from the output of a command?

if I have sth. like echo 1 2 3 4 5 6 or echo man woman child what do I have to put behind the pipe to pick out one element of 1 2 3 4 5 6 or man woman child ? echo 1 2 3 4 5 6 | command 3
3
votes
3answers
140 views

Using /dev/random, /dev/urandom to generate random data

I'm looking for ways to use /dev/random (or /dev/urandom) from the command line. In particular, I'd like to know how to use such a stream as stdin to write streams of random numbers to stdout (one ...
2
votes
2answers
57 views

Would draining entropy make it easier to compromise a system? [duplicate]

Entropy is important for many security features like TCP sequence numbers and cryptographic key/parameter generation. My understanding is that the entropy pool is drained by an operation as simple as ...
3
votes
3answers
463 views

How can I shuffle pages from a pdf file in a random order?

I would like to shuffle the pages of a pdf document in a random order. How can this be done?
8
votes
1answer
278 views

Is it wrong to link /dev/random to /dev/urandom on Linux?

I'm currently testing gpg --genkey on a Linux VM. Unfortunately, this software seems to rely on /dev/random to gather entropy and politely asks the user to manually type screens after screens of ...
22
votes
9answers
42k views

Generate random numbers in specific range

After googling a bit I couldn't find a simple way to use a shell command to generate a random decimal integer number included in a specific range, that is between a minimum and a maximum. I read ...
1
vote
4answers
50 views

Rename files randomly but without repetition

Suppose i have a folder with a lot of file names some very strange and nonsense I want to rename it like File-1 File-2 File-3 .. I have tried this(echo is for tryng) for name in *; do echo mv $...
1
vote
2answers
70 views

Generate unique numbers RANDOM function OS X

I am creating a random generator based from a number array list. However, I would like it to be unique so that random number cannot be used again. I have tried creating a 'USED' array list which will ...
11
votes
4answers
5k views

Create random data with dd and get “partial read warning”. Is the data after the warning now really random?

I create a 1TB file with random data with dd if=/dev/urandom of=file bs=1M count=1000000. Now I check with kill -SIGUSR1 <PID> the progress and get the following: 691581+0 Datens├Ątze ein 691580+...
9
votes
5answers
7k views

Fast Way to Randomize HD?

I've read about how to make hard drives secure for encryption, and one of the steps is to write random bits to the drive, in order to make the encrypted data indistinguishable from the rest of the ...
1
vote
1answer
35 views

Password Generator not working OS X

I am creating a Password Generator using 4 Arrays (Lower Case, Upper Case, Symbol and Number) with the RANDOM function. Basically I will generate a random number and then apply it to each of those ...
0
votes
1answer
85 views

How to create a dynamic greeting?

Recently made the switch to Linux/command line, and I'm having trouble creating a dynamic greeting for terminal out of a list of predetermined possibilities. I tried the following, but it appears as ...
1
vote
2answers
53 views

Appending Echo [Password Generator]

I am creating a password generator however I am not get the passwords to append properly. Here is my script i="0" while [ $i -lt 5 ] do echo -n '#' >> passwords.txt && openssl rand ...
3
votes
4answers
157 views
2
votes
3answers
150 views

Random number generation in Solaris?

What is the best way to generate random numbers in Solaris? I can not seem to find a good answer for this. Most results do not work in my environment. There is a variable or command RAND that seems ...
3
votes
1answer
3k views

Debian Jessie - Random freezes

I have a fresh installation of Debian Jessie, with Cinnamon and Gnome. I run it on a decent computer with the following specs: Athlon II x3, 6GB DDR2, 2GB SWAP (swapiness minimum), 600GB SATA HDD (...
16
votes
3answers
12k views

Reading from /dev/random does not produce any data

I often use the command cat /dev/urandom | strings --bytes 1 | tr -d '\n\t ' | head --bytes 32 to generate pseudo-random passwords. This doesn't work with /dev/random. Specifically cat /dev/...
28
votes
8answers
10k views

How to generate a random string?

I would like to generate a random string (e.g. passwords, user names, etc.). It should be possible to specify the needed length (e.g. 13 chars). What tools can I use? (For security and privacy ...
3
votes
5answers
61 views

How do I exchange names for a large amount of files in a folder?

I want to randomize the names for about 350 files in a folder, but I want to have all the names that the files had originally. What I mean is I want All of the names in my folder randomized from the ...
0
votes
1answer
26 views

Generating files of varying variability?

I have used /dev/zero and /dev/random to generate files of certain size. However, is there a way to control variability of generated files? I would like to create few files that would have same ...
2
votes
3answers
114 views

Duplicate a file with random probability

I have a directly full of images and I am trying to put together a script/command that will randomly copy (with some probability) the image to a location with a random name at that destination (...
6
votes
3answers
449 views

Print random lines respecting the order of the source file

I have a large text file (~500K lines) with short sentences (couple of words long). Additionally, there is some XML markup in most of the lines. Finally, the text file has been sorted before the ...
3
votes
2answers
339 views

Is it bad to have a low entropy in /dev/random?

I wonder whether for the average Linux user it is considered as bad -from a point of view of security or any other relevant viewpoints- to have no or almost no entropy left in /dev/random. Edit: I ...
4
votes
1answer
195 views

Shuffle two parallel text files

I have two sentence-aligned parallel corpora (text files) with about 50 mil words. (from the Europarl corpus -> parallel translation of legal documents). I'd now like to shuffle the lines of the two ...
1
vote
2answers
138 views

Randomly copy certain amount of certain file type from one directory into another

Sometimes I have a folder full of jpg's and I need to randomly choose 8 or so of them. How could I automate this so my account randomly chooses 8 jpg's from the folder and copies them to another ...
2
votes
2answers
218 views

How to generate a random string in a profile alias?

I have an alias in my server's /etc/profile which generates a random directory on command, like this: alias rdir="mkdir -p ./`cat /dev/random | tr -cd 'a-z0-9' | head -c 8`/" But it turns out this ...
17
votes
4answers
9k views

Why can't tr read from /dev/urandom on OSX?

A colleague suggested creating a random key via the following command: tr -dc A-Za-z0-9_\!\@\#\$\%\^\&\*\(\)-+= < /dev/urandom | head -c 32 | xargs It gave me the error: tr: Illegal byte ...
1
vote
3answers
86 views

Random sampling and outputting the largest value

I have a fairly large data set ~500 million rows. The data set looks like below. Col 1 is float number, col 2 is mac id(device id) 1616.93,ac:22:0b:a6:22:c3 2872.32,c0:bd:d1:36:bb:49 3314.55,d4:0b:1a:...
0
votes
3answers
78 views

How to achieve “continuos randomness”?

With RANDOM%xone gets a set of discrete results. How can I achieve following scenario?: Inside a for loop, I'd like to let a bash script execute command A in 33.33% of all loops and else execute ...
6
votes
5answers
924 views

Sources of Entropy for Linux

Let's say I want a gigabyte or so of random data from /dev/random, suitable for a one-time pad (so /dev/urandom is out.) How do I seed my /dev/random with enough entropy to do this? I am looking for ...
4
votes
2answers
191 views

Decreasing or emptying the entropy pool?

I work with virtual machines a lot, and they seem to generally be low on entropy (no mouse or other entropy-generating inputs). A bug with my software has surfaced, and I think it's due to running out ...
5
votes
1answer
479 views

How to copy a file several times into randomly choosen paths within the filesystem?

I have a filesystem and a special file foo. I would like the script to choose several times (5,10 or 100) random paths to folders within this filesystem and to copy the file foo into each of them. ...
15
votes
4answers
6k views

Tool for measuring entropy quality?

Is there a tool available for Linux systems that can measure the "quality" of entropy on the system? I know how to count the entropy: cat /proc/sys/kernel/random/entropy_avail And I know that some ...
4
votes
2answers
543 views

Generating file with ASCII numbers using /dev/urandom?

How can I generate 10 MB files from /dev/urandom filled with: ASCII 1s and 0s ASCII numbers between 0 and 9
4
votes
4answers
677 views

How to fill a file with a stream from /dev/urandom with a specified number of lines ?

I am trying to fill a file with a sequence of random 0 and 1s with a user-defined number of lines and number of characters per line. the first step is to get a random stream of 0 and 1s: cat /dev/...
21
votes
4answers
8k views

Why does dd from /dev/random give different file sizes?

I am running the following command on an ubuntu system: dd if=/dev/random of=rand bs=1K count=2 However, every time I run it, I end up with a file of a different size. Why is this? How can I ...
2
votes
3answers
217 views

gpg key generation on Tails live cd - why so quick?

I just used gpg2 --gen-key to generate a 2048 bit RSA key pair on an OS running on a live cd (Tails). This happened much faster than I expected. When I have done this before on a regular machine it ...
2
votes
1answer
979 views

Changing the hostname on a Linux Mint desktop to a random value at boot time

When changing the hostname to a random set of alphanumeric characters on a machine running Linux Mint(17.1 Rebecca, Cinnamon 64-bit) I encounter some problems. The following script changes the ...
3
votes
1answer
53 views

How random is the pseudo random number generators on live boot disks? Is there a way to seed it?

I know that random number generators on computers are only pseudo-random, but are the PRNGs on Live Boot USB or DVDs even less random? Is there a way to seed them after booting? Specifically curious ...
3
votes
2answers
399 views

How to quickly generate (insecure) GPG keys?

I'd like to automate generating at least two GPG keys for testing and demonstration purposes in a virtual machine. Because of this context I want to make sure the key generation is fast, ideally not ...
0
votes
1answer
118 views

php shell_exec() + /dev/hwrng: no output

I have this PHP script: <?php $od = shell_exec('od /dev/hwrng --address-radix=n --read-bytes=4 --format=u4'); ?> <html> <head> <title>hwrng</title> </head> &...