Questions tagged [random]

UNIX random devices and utilities

0
votes
1answer
26 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[@]}...
1
vote
1answer
24 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
482 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
39 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
66 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
42 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
22 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
17 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
47 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 /...
0
votes
4answers
191 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 ...
0
votes
0answers
24 views

Where is the default value of write_wakeup_threshold defined?

When reading /proc/sys/kernel/random/write_wakeup_threshold on various Linux systems I get different values. So I assume its default value is not generic but might depend on the Linux distribution, ...
6
votes
2answers
2k 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
75 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
287 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
51 views

Pick random row from a file [duplicate]

How do I pick a random row of text from a file?
1
vote
1answer
62 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
83 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 ...
5
votes
1answer
6k 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
1k 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
133 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
118 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
84 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
509 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
879 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
5k 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
490 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
3k 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
658 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
589 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 ...
2
votes
2answers
755 views

How temporary is the output of cat /dev/urandom

I am using the following command on my server to create a seed: cat /dev/urandom |tr -dc A-Z9|head -c${1:-81} If I copy the output and then close the terminal, will the created seed be completely ...
4
votes
1answer
1k views

Why is the random seed only saved to disk on boot and shutdown?

On my system, there's /var/lib/systemd/random-seed. On boot, it's loaded it into the entropy pool and replaced with a new one. On shutdown, entropy is saved to it. I didn't find anything changing it ...
3
votes
2answers
84 views

improve mock data generation

I'm trying to generate csv with mock data for i in {1..1000000..1} do echo "$i,$(date -d "2017-08-01 + $(shuf -i 1-31 -n 1) days" +'%Y-%m-%d')" >> $F done; looping from 1 to million and ...
0
votes
2answers
219 views

Generate random number for x amount of time in BASH

I would like to generate random numbers for "x" amount of time, but I'm not sure how to make it run for x amount of time (like 2 minutes for example).
2
votes
1answer
181 views

CentOS PXE/Anaconda/kickstart waiting to gather enough entropy

When kickstarting a CentOS 7 system, with configuring full disk encryption, the anaconda process either hangs on obtaining enough entropy or will take the entire 10 minutes (timeout period). Is there ...
3
votes
1answer
782 views

libkcapi - Error: Netlink error: cannot open netlink socket

I am trying to play with my random generator, so I decided to give libkcapi a try. Here is what I did: $ wget http://www.chronox.de/libkcapi/libkcapi-0.13.0.tar.xz $ tar xf libkcapi-0.13.0.tar.xz $ ...
2
votes
0answers
84 views

Are any distros implementing a more secure CSPRNG in KASLR than RDRAND in lib/kaslr.c as in the vanilla sources?

I started with kaslr.c and found that it uses kaslr_get_random_long() defined in kaslr.h and implemented in lib/kaslr.c where it possibly uses RDRAND (Intel's hardware PRNG), a timestamp, and at ...
1
vote
2answers
1k views

What are the --use-urandom or --use-random options in LUKS used for?

I'm currently trying to teach myself some non-Windowsland operating systems, and I figured Ubuntu Server 16.04 would be the best place to start. Having "mastered" LVM, I'm trying to familiarize ...
1
vote
0answers
1k views

high cpu usage when executing scripts on rhel 7 VM coming from rngd

I'm moving a physical server to a VM (rhel 7.3) and while running a fairly basic script I noticed that CPU usage was very high for what I was executing. After a little investigation I found that if I ...
-2
votes
1answer
2k views

/dev/urandom returning same value every time [closed]

EDIT I: Windows subsystem for Linux. I bet I'm doing something wrong and/or really stupid. // random_problems.c #include <stdio.h> main(){ int rng; FILE * urnd = fopen("/dev/random", "r")...
2
votes
1answer
523 views

Generate XKCD passwords from single Bash line [duplicate]

There are a few "XKCD password" generators out there, but the task seems so straight forward, so I wanted a compact and simple solution. My requirements were: One-line alias (or few-line function) to ...
7
votes
2answers
1k views

What does “w” do with urandom?

> strace w 2>&1 | grep urandom read(4, "/usr/bin/grep\0urandom\0", 2047) = 22 > Why does "w" need urandom? How to avoid this? UPDATE: > strace w 2>&1 | awk '/urandom/' read(...
2
votes
1answer
118 views

Using BSD jot for generating file with random content

Quote from Using BSD jot Most every Linux system comes with GNU seq (a utility to generate sequences of numbers or characters). However, a much older utility – and more flexible one – is the ...
2
votes
2answers
271 views

Using the NeuG TRNG with /dev/random?

I've got a NeuG hardware true random number generator (http://www.gniibe.org/memo/development/gnuk/rng/neug.html) and its page says that it runs on GNU/Linux systems as /dev/ttyACM0 Can I configure /...
6
votes
2answers
500 views

Generate big amount of pseudorandom data predictably

I bought cheep 2 TB HDDs (60 € each) and want to check whether they return the data they were fed when reading before using them. I checked some cheep thumb drives drives by copying large files I had ...
1
vote
3answers
145 views

How to randomly subset a file and then select the same line numbers from multiple files

I have a file that contains 3494 lines, of which I would like to randomly select 100, and write those lines to a new file. I can do that using this: shuf -n 100 input_file.txt output_file.txt ...
2
votes
3answers
604 views

Bash script to give random extension to the filename

I am trying to make a bash script for OSX that adds an alphanumeric extension at the end of the file. I can't find how to make the random 6 character. Ex filename_cod_45fg43.zip Here the script: ...
2
votes
2answers
1k views

Can having low entropy cause an HTTPS server to be slower?

We are very low on entropy (HW: Lenovo ThinkCentre M58, OS: Ubuntu 12.04, not a VM, SW: HTTPS Apache server): root@server:~# cat /proc/sys/kernel/random/entropy_avail 417 root@server:~# Question: ...
3
votes
0answers
708 views

Check if /dev/urandom has been properly seeded in Linux

Myths about /dev/urandom says that in rare cases very shortly after boot, the CSPRNG may not have had enough entropy to be properly seeded and /dev/urandom may not produce high-quality randomness. ...
3
votes
0answers
6k views

Linux kernel boot: uninitialized urandom read (16 bytes read)

In dmesg, I see the following entries: [ 0.989416] random: systemd-tmpfile: uninitialized urandom read (16 bytes read) [ 0.989708] random: systemd-tmpfile: uninitialized urandom read (16 bytes ...