Questions tagged [random]

UNIX random devices and utilities

Filter by
Sorted by
Tagged with
1 vote
3 answers
51 views

Different $RANDOM results in sed when reading lines in multiple files

I'm trying to run a command that will read multiple files in a directory, look at each line of each file, and whenever it reads a specific string ("gene_height") on any line it replaces 2 ...
user avatar
2 votes
1 answer
208 views

Different behavior of RANDOM and URANDOM on Rpi Buster

System is: pi@titania:~ $ cat /etc/os-release PRETTY_NAME="Raspbian GNU/Linux 10 (buster)" NAME="Raspbian GNU/Linux" VERSION_ID="10" VERSION="10 (buster)" ...
user avatar
  • 29
5 votes
2 answers
752 views

kernel 5.10.119 caused the values of /proc/sys/kernel/random/entropy_avail and poolsize to be 256

After update to kernel 5.10.119, /proc/sys/kernel/random/entropy_avail became stuck to 256 and does not change when moving the mouse. It used to be greater than 3000. # cat /proc/sys/kernel/random/...
user avatar
0 votes
1 answer
30 views

Won't the new nonblocking architecture for /dev/random make it less secure?

If entropy is not accounted for, and the pool doesn't block even if insufficient entropy has been supplied, isn't it potentially insecure?
user avatar
  • 101
21 votes
3 answers
3k views

How can I force /dev/random to block?

For a class on cryptography, I am trying to drain the entropy pool in Linux (e.g. make /proc/sys/kernel/random/entropy_avail go to 0 and block a command reading from /dev/random) but I can't make it ...
user avatar
0 votes
1 answer
118 views

Random float sleep in bash script?

I need randomized pauses in my script between two numbers smaller than 1 second in my script. The following used to work: #! /bin/bash sleep $(python -c "import random;print random.uniform(.2,.8)&...
user avatar
  • 3
-1 votes
1 answer
123 views

Pick random line from a compressed text file with zcat/gz or altnernatives

I have a simple bash script that picks a random line from a text file. This is originally done with shuf file.txt | head -1 (the same result can be achieved with cat file.txt | shuf | head -1). I also ...
user avatar
-2 votes
2 answers
77 views

bash error syntax random number [closed]

My assignement is to show a random number (od -vAn -N4 -tu4 < /dev/urandom) between two numbers in read. I don't understand why there are syntax error when I check the min value exception and with ...
user avatar
4 votes
3 answers
580 views

Random number output between two ranges linked together

This question is about generating random numbers between a range, which is fine, but it doesn't fit my case. I'll explain in SQL terms because it seems to me that's easier to understand, though the ...
user avatar
0 votes
3 answers
67 views

How to create a random complex password in SuSe 12

I need a way to generate a random password following this requirements: Password at least 9 characters at least 2 capital letters at least 2 small letters at least 2 digits at least 2 special ...
user avatar
6 votes
2 answers
948 views

syslog message at boot: uninitialized urandom read

CPU is AMD GX-412TC SOC: GX-412TC GE412TIYJ44JB 4 6W 2MB 1.0GHz/ 1.4GHz N/A N/A DDR-1333 0-90°C which does not have rdrand: grep rdrand /proc/cpuinfo # nothing I see following messages in my syslog ...
user avatar
0 votes
0 answers
29 views

How to intentionally minimize the system entropy

My question might seem counter-intuitive at first, as most of the time people want to do the opposite (i.e., increase entropy). I have a few USB devices that act as random number generators -- namely, ...
user avatar
  • 141
0 votes
0 answers
32 views

Reading an infinite data in Python and feeding to another external process

I am using Python to read data from a TRNG (true random number generator) device, and I want to feed this data to an external utility (e.g., dieharder). The data itself is an indefinite stream, but ...
user avatar
  • 141
1 vote
2 answers
510 views

How can I configure RANDOM for getting the same 32 bit range of random numbers, like by using SRANDOM?

Environment: Debian Bash What is known: RANDOM gives a random number in a range of 15 bits by the following: echo $RANDOM SRANDOM gives a random number in a range of 32 bits by the following: echo $...
user avatar
  • 155
0 votes
2 answers
350 views

Putting the contents of /dev/urandom into a variable?

This is a follow on from my previous thread :- Passing date command into a variable? Ok so effectively I would like /dev/urandom to generate 4 digits for me. And place them into a variable. Here is an ...
user avatar
  • 25
3 votes
2 answers
258 views

What if I have a bad (static, low entropy) random-seed in systemd?

On embedded systems, read-only filesystems are common. Read-only means that /var/lib/systemd/random-seed cannot be updated on reboot, and is probably a clone of another device's random-seed. Does this ...
user avatar
3 votes
3 answers
864 views

Create Numbers 1-6 in random order using AWK

I'm using AWK to generate values between 1 - 6 which need to come out in random order. I have managed to sort out the logic for the creation of the right range of numbers but am struggling with ...
user avatar
-4 votes
2 answers
191 views

random output from input

Related question : how to create a random output from users input I was thinking to take an input(only one argument) from user just like Hello. And, I want to give output like olleho llohe he llo lo ...
user avatar
0 votes
1 answer
93 views

Why is counting repeated numbers from /dev/urandom the same on every system?

This command, which generates numbers from /dev/urandom and prints how many repeated numbers there are, returns the same on every system. Why? dd if=/dev/urandom count=1 bs=5M 2> /dev/null | od - | ...
user avatar
  • 3
-1 votes
1 answer
373 views

Replacing numbers in a text file in each iteration with random values

I have a text file with the following content: number of apples 7 I would like to run the shell script and modify the number with random values for say 5 iterations. So I need my output to look like ...
user avatar
2 votes
3 answers
1k views

How to generate a comma separated list of random ints

I am trying to generate a comma separated unordered list of ints between 1 and 10, I have tried the following but it results in an ordered list: seq -s "," 10 | shuf
user avatar
  • 23
11 votes
2 answers
3k views

/dev/random EXTREMELY slow in Ubuntu for Windows 10 (WSL)

I am using Ubuntu 20.04 for Windows 10 (WSL2) on a Haswell laptop and I am getting about 0.6 bytes per second. As in 6 bytes total after 10 seconds of waiting. This is unacceptable. What is the ...
user avatar
  • 248
0 votes
1 answer
118 views

why reading from `/dev/random` put `1;2c` character behind the cursor? [duplicate]

when I run command dd if=/dev/random count=1 bs=32 I get some random junk binary data but after receiving them, there is still some characters (as I see always 1;2c) after termination of dd process. [...
user avatar
0 votes
1 answer
22 views

Seed executables randomization outside of code

We have put in place a features test framework which consists in running our code against some third partie`s pre-existing software. We do so periodically and compare the results with expected results ...
user avatar
  • 101
0 votes
2 answers
257 views

How to sample without replacement from a script that randomly extracts 200characters using shuf?

I have this script that extracts 200 random characters from a set: #!/usr/bin/bash n=$(stat -c "%s" newfile.txt) r=$(shuf -i1-"$((n-200+1))" -n1) < newfile.txt tail -c+"$r&...
user avatar
  • 37
0 votes
0 answers
52 views

Could a new AMD processor be limiting dd write speed when using /dev/urandom as the input?

I have recently bought a new computer that uses a pretty recent AMD Athlon chip. When using it for low-level formatting with dd, I noticed that setting if=/dev/zero allows it to write to the disk at ...
user avatar
0 votes
1 answer
134 views

How to replace Shuf with rand (from C++) with a seed of time in order to make my script more random [closed]

I have this script that extracts 200 random characters from a set: tail -n+2 file.fasta | tr -d '\n' > newfile n=$(stat -c "%s" newfile) r=$(shuf -i1-"$((n-200+1))" -n1) newfile ...
user avatar
  • 37
0 votes
2 answers
341 views

How to use a for loop in order to save the output from a script into single files

I got help subtracting a random 200 sequence from a fasta file like this: JQ086372.1 Enterobacteria phage HK446, complete genome ATGGCAGATAAACGAATCCGTTCCGACAGTTCGGCGGCAGCGGTTCAGGCCATGAAAAATGCAGCTGTGG ...
user avatar
  • 37
1 vote
4 answers
355 views

How to randomly extract a substring of 200 characters from a fasta file

Is there any Linux command one can use to extract a sequence from a file? For instance, a file contains one million lines, and we want to randomly sample only a sequence of 200 characters from that ...
user avatar
  • 37
2 votes
0 answers
379 views

rngd is running with /dev/hwrng; boot hangs long at "Initalizing entropy source hwrng"

My i.MX6 machine with yocto linux takes horribly long to boot. On the console I can see that it's hanging at initializing the hardware random number generator: Starting system message bus: [ 8....
user avatar
  • 11.7k
6 votes
2 answers
1k views

Reading from dev/urandom - system behaviour

When reading from dev/urandom, with say head or dd, it’s of course expected that the output is always random and different. How is this handled by UNIX at a low level? Is the file naturally truncated ...
user avatar
  • 336
0 votes
2 answers
93 views

generate a password with minimum 2 numbers, 2 CAPS, 1 symbol, x lower alpha and max length of 16

I tried pwgen and makepasswd to generate a password... but these are not enough to generate with exact count of literals and numbers... pwgen -c -n -y -B 12 1 This is not working as expected as I ...
user avatar
  • 932
0 votes
1 answer
69 views

Write all numbers between 0 and large number (both inclusive) to a file in random order

For simulation I am trying to do, I want a text file with numbers ranging from 0 to 2^33 which is a huge number. I have used this command: seq 0 Number >> OUTPUT FILE But this is very slow. ...
user avatar
  • 101
5 votes
1 answer
1k views

Generate a random time between 00:00:20 and 10:10:00

I want to generate a somewhat random time signature in a bash script using a variable. I've got a video file that's 11 hours long and I'll be muxing a 50-minute mp3 podcast that I download most ...
user avatar
  • 361
2 votes
1 answer
571 views

How to cat a specific tone to /dev/audio?

cat /dev/urandom generates a random sequence of all possibles "values". cat /dev/urandom | padsp tee /dev/audio > /dev/null directs these "values" to your audio device, turning them into "random ...
user avatar
1 vote
1 answer
596 views

Select a random file from the file system [duplicate]

Is there a way to get the path of a random file from the entire file system (either from a single partition or everything under /), in a reasonable time?
user avatar
  • 277
0 votes
1 answer
1k views

Run two commands one after another in bash, via a function, called with `eval`

I am facing problems running two commands one after another in bash.  When I run source2() { '/home/ds/Documents/scripts/Untitled Document 1.sh' && imgpath="$(ls | grep "^unsplash&...
user avatar
  • 304
0 votes
2 answers
820 views

How can i store commands as a variables and execute them randomly in bash?

How can i store commands as a variables and execute them randomly in bash? command1=" convert -size 2000x1000 xc:none -gravity center \ -stroke yellow -pointsize 50 -font Courier-BoldOblique -...
user avatar
  • 304
3 votes
2 answers
104 views

Help with Kindle e-ink - display random image file

I am a complete newby to this but I'm trying to adapt someone else's code for a jail broken Kindle 3 (e-reader). I am using the following code to generate a random(ish) number between 0 to X (where X ...
user avatar
0 votes
1 answer
2k views

4000x "wpa_supplicant[1885]: random: Cannot read from /dev/random: Resource temporarily unavailable" log message when booting

I recently added Linux Mint (19.3) as my new main OS on my Sony Vaio notebook. Sometimes booting takes a bit of time and I found in jounrnalctl: Feb 11 10:45:11 notebook kernel: microcode: microcode ...
user avatar
  • 113
0 votes
2 answers
1k views

Can you feed urandom to dd for wiping a drive but skip every other block to speed it up?

I've been wiping a large number of old laptops for donation/recycling. To do so I boot up to a Linux live CLI from USB or CD and use dd if=/dev/urandom of=/dev/sda status=progress to overwrite the ...
user avatar
  • 1
0 votes
2 answers
389 views

Why does it take longer to create a file with random text than with zeros?

i recently created a test file, because I wanted to play around with logrotate. I was searching for a solution to create a file with any size I want. I found out that this is my solution: dd if=/dev/...
user avatar
  • 21
2 votes
0 answers
211 views

Do Mediatek SoCs (specifically MT7628) have linux accessible RNG hardware?

I am dealing with a custom board based on a MT7628AN SoC. Currently it takes a LOOOOOOONG time to initialize the entropy pool: [ 1857.972285] random: crng init done That is about half an hour! I ...
user avatar
  • 738
5 votes
1 answer
457 views

Returning randomised items from glob match

With the glob qualifiers in zsh one can sort the results of a filename globbing pattern match in various ways. For example, the pattern *(om) would match all non-hidden names in the current directory,...
user avatar
  • 272k
3 votes
1 answer
440 views

Immediate effect of writing to /dev/random

For reasons best described as philosophical, I'd like to know the following. Assume I am going to read from /dev/random (or /dev/urandom) at time X. In one scenario I just do that, but in another, ...
user avatar
  • 325
14 votes
5 answers
4k views

How could a sequence of random dates be generated, given year interval?

What is needed here is a command that generates six dates given a range of years (1987 to 2017). For example: 12/10/1987 30/04/1998 22/02/2014 17/08/2017 19/07/2011 14/05/2004 How it could be done, ...
user avatar
  • 163
2 votes
1 answer
555 views

Adding entropy to /dev/random

I'm in the process of designing and building a quantum random number generator for high security applications (and potentially data centres). As part of this, I would like to feed the random numbers ...
user avatar
2 votes
1 answer
890 views

How can I speed up random init? [duplicate]

I have an embedded device running a linux environment built with Yocto. I have both openssh-server and nginx running, both of which take 1 minute to start because they are waiting on enough entropy: ...
user avatar
  • 275
3 votes
1 answer
2k views

Linux embedded: boot stopped by "crng init" for LOOOOONG time

I am having heavy problems similar to what discussed in this question. In my case though, I have a very recent kernel (5.3) for a small embedded processor (mips, mt7628) and boot process stops for ...
user avatar
  • 738
-1 votes
2 answers
687 views

Creating random file in just one line but with specific length

I want to make a file (random content) but with just one 1 MB large line inside it I have tried using this command but it didn't work : head -n 1 -c 1m /dev/urandom > /sdcard/file.txt How ...
user avatar

1
2 3 4 5