Questions tagged [random]

UNIX random devices and utilities

Filter by
Sorted by
Tagged with
2
votes
1answer
66 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 ...
1
vote
1answer
91 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?
0
votes
1answer
62 views

Run two commands one after another in bash

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")" } ...
0
votes
2answers
53 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 -...
3
votes
2answers
51 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 ...
0
votes
1answer
196 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 ...
0
votes
2answers
51 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 ...
0
votes
2answers
61 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/...
2
votes
0answers
29 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 ...
4
votes
1answer
104 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,...
3
votes
1answer
100 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, ...
12
votes
5answers
2k 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, ...
2
votes
1answer
73 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 ...
2
votes
1answer
167 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: ...
3
votes
1answer
223 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 ...
-1
votes
2answers
90 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 ...
15
votes
5answers
2k views

How to run a command 1 out of N times in Bash

I want a way to run a command randomly, say 1 out of 10 times. Is there a builtin or GNU coreutil to do this, ideally something like: chance 10 && do_stuff where do_stuff is only executed 1 ...
0
votes
0answers
86 views

FreeBSD: how can I check if `/dev/random` is blocking?

So this exact question has been asked many times about Linux's implementation of /dev/random, but I am struggling to find an answer that is FreeBSD specific. From the FreeBSD random(4) man page: ...
9
votes
2answers
2k views

Is dd if=/dev/urandom of=/dev/mem safe?

What exactly does this do? I don't understand how you could access base memory with this...seems kinda weird. Is it safe? dd if=/dev/urandom of=/dev/mem
1
vote
0answers
63 views

How to grep an eternal string coming from STDIN

Using bash i'm trying to grep a string coming from /dev/urandom something like this: tr -cd '[:lower:]' < /dev/urandom | grep -o 'test' Also tried: tr -cd '[:lower:]' < /dev/urandom | grep -o ...
15
votes
2answers
4k views

Why am I getting unevenly-spread results when using $RANDOM?

I read about RNGs on Wikipedia and $RANDOM function on TLDP but it doesn't really explain this result: $ max=$((6*3600)) $ for f in {1..100000}; do echo $(($RANDOM%max/3600)); done | sort | uniq -c ...
0
votes
1answer
241 views

Bash: how to avoid duplicate result from random list?

Suppose a script like this #!/bin/bash array[0]="123" array[1]="333" array[2]="5566" array[3]="135" array[4]="68" array[5]="45" array[6]="78" array[7]="32" array[8]="190" number() { size=${#array[@]}...
2
votes
1answer
45 views

How should I go about safely checking if performing dd on /dev/random is going to block?

I'm developing a shell script that only uses /dev/random in the following manner: dd if=/dev/random of=%{outputFile} count=512 bs=1 2>/dev/null I explicitly do not want to use /dev/urandom, even ...
4
votes
4answers
1k views

Using sed to replace “A” with a “B” or “C”

This should be straight-forward, but I cannot figure it out. If I want to replace an A or B with a C using sed the code could potentially be: $ echo AAXXAAYYBB | sed 's/[AB]/C/g' CCXXCCYYCC This ...
0
votes
1answer
916 views

RPi + Buildroot: random: crng init done (not enough entropy) - how to configure rng-tools

I'm designing a minimal custom Buildroot embedded OS for the RPi0w. My current iteration takes a very long time to fully boot - several minutes with a keyboard and mouse plugged in, and tens of ...
1
vote
3answers
72 views

Replace the last alphanumeric with a random char of same type [closed]

I have a simple list of alphanumeric machine names in a file, and I want to change the last letter or number, but I want it to match character type -- so if the last character is a digit, it should be ...
2
votes
2answers
147 views

Feed /dev/random by Octeon RNG

The device is Octeon by Cavium which contains a RNG hardware unit. OS shows that the current entropy pool size is 4096 bytes but entropy_avail is very low. The device crypto modules has ansi_cprng.ko ...
0
votes
1answer
40 views

Increase entropy_avail on Cavium

The device is Octeon by Cavium which contains a RNG hardware unit. OS show Current entropy pool size is 4096 bytes but entropy_avail is very low.The device crypto modules has ansi_cprng.ko present ...
0
votes
1answer
100 views

PRNG not seeded (on SCO OpenServer 5.0.7 MP5)

On SCO OpenServer 5.0.7 MP5, upon attempting use of any ssh-based utility, the following is returned, and any intended SSH connection does not occur: PRNG not seeded How is this resolved (the ...
0
votes
0answers
102 views

randomly generated words to a form using curl

What I want to achieve is to post a form containing 3 fields (forename, surname and email) to a url, but i want the entries to be randomly generated. I want to generate a random word using; { head /...
2
votes
4answers
1k views

How to shuffle file names randomly in a directory

Say i have a directory of filenames: file_010.ext file_011.ext ... file_99.ext What's the simplest way to take each file and randomly rename it to any other name in the directory, without there ...
7
votes
2answers
5k views

Create unique random numbers (UUIDs) in bash

I want to create random unique numbers (UUIDs) as the following node.id=ffffffff-ffff-ffff-ffff-ffffffffffff First I tried this $ rndnum=` echo $RANDOM"-"echo $RANDOM"-"echo $RANDOM"-"echo $RANDOM"-...
-3
votes
1answer
483 views

random test log generator [closed]

I need to write a script to create random test log data. Log data should be delimited with "|"(pipe) and 10,000 lines with 500 bytes, and each line and contain following format with random data. ...
6
votes
2answers
313 views

How do I specify chance when setting a variable to random item in array?

Currently I do something like this to set a variable to a random item in an array: array=("foo" "bar" "baz") var=${array[$RANDOM % ${#array[@]} ]} How would I do if I want to set $var to one of ...
1
vote
0answers
56 views

Pick random row from a file [duplicate]

How do I pick a random row of text from a file?
1
vote
1answer
244 views

Does the size of the random_source file matter?

Some GNU coreutils utilities like sort and shuf use a file as what effectively serves a seed. Does the size of the file matter? The recommended way, https://www.gnu.org/software/coreutils/manual/...
1
vote
1answer
257 views

Weird behavior in zsh random generator

I have this script to generate $1 digit(s) of mixed random char from the defined charlists as arrays. #!/bin/bash charlist1=(a b c d e f g h i j k l m n o p q r s t u v w x y z) charlist2=(0 1 2 3 4 ...
6
votes
1answer
8k views

Debian Testing takes a long time to load. Crng init done [closed]

Debian Testing takes a long time to load. Here is a fragment of the dmesg log. kernel - 4.17 [ 11.296697] audit: type=1400 audit(1533745556.133:9): apparmor="STATUS" operation="profile_load" ...
8
votes
3answers
2k views

My script produces the same output when using $RANDOM

I am trying to print a random n letter word, where I input n from the command line itself, but for some reason my script is giving me the same answer every time when using the same value for n. #!/...
1
vote
2answers
2k views

Generate random password with special characters on Solaris

I am trying to generate a 10-character random password in Solaris servers. The examples give around the web are for Linux and mostly not working in Solaris.
3
votes
1answer
245 views

Snail rate of “entropy creation” not increasing significantly with rng-tools

The rate of "entropy creation" on my system (Linux 4.13.0-38-generic, 16.04.1-Ubuntu, Intel® Celeron(R) CPU G3930 @ 2.90GHz × 2, main disk is SSD) is an impractically slow much less than 1 bit per ...
0
votes
1answer
158 views

If /dev/random is implemented as a pseudo-device, why isn't “yes”? [closed]

yes produces a stream of "y" chars, or other requested. If Unixen have a pseudodevice for random numbers, why not useful streams like this too?
-3
votes
1answer
125 views

Eval not working

i try run this code to get random number but eval seems not working this is my code #!/bin/bash # Sequencia alfanumerica de 12 carateres aleatoriamente (maiusculas e minusculas) file="/home/...
3
votes
1answer
914 views

How can I make initializing random non blocking pool faster?

I have an issue with my Buildroot generated Linux and rootfs image for Zynq board. The problem is that random nonblocking pool is generated about 2 minutes after boot, just after I get kernel message ...
5
votes
2answers
994 views

Generate random number after value in bash

I want my machine to automatically download some files. That doesn't have to be very efficient. So I decided to do this with a bash script. It works so far when I encode the URL hardly. But I want ...
5
votes
6answers
8k views

Bash: How to generate random float number using $RANDOM

Is it possible to generate real random numbers with a specific precision and in a specific range using the Integer Random Generator $RANDOM? For example how we can generate real number with 4 ...
2
votes
2answers
705 views

Only allow given number range from /dev/urandom

In GENERAL, on Linux, UNIX, BSD, cygwin systems, how can I get random numbers from /dev/urandom inside a given range, example: 217 < X < 34523 OR other example: 36856 < X < 76543 I ...
8
votes
1answer
5k views

Bash RANDOM with seed?

I've been using $((1 + RANDOM % 1000)) to generate a random number. Is it possible to do something similar but provide a seed? So that given the same seed the same random number will always be ...
-1
votes
1answer
1k views

How to copy random files to a directory

First of all it isn't a homework. I just don't want to dig through a bunch of manuals and learn to program shell from A-Z to do this one thing. I have a folder /mnt/hdd/files with lots of subfolders ...
2
votes
0answers
948 views

/dev/random entropy on readonly file system

My hostapd works very well on my raspberry Pi3. But if I put root filesystem in readonly, it does not work. I have put some folders like /var/run and /tmp in a ramdisk filesystem. I have seen ...