Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [random]

UNIX random devices and utilities

0
votes
1answer
12 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
36 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
94 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
18 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
1k 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
61 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
281 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
50 views

Pick random row from a file [duplicate]

How do I pick a random row of text from a file?
1
vote
1answer
40 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/...
0
votes
1answer
271 views

rng-tools allows /dev/random depletion

I'm trying to understand what is going on with rng-tools and systemd on a Beaglebone Black dev-board that's leading to entropy depletion in /dev/random. I have about 8 dev-boards in a similar ...
1
vote
1answer
71 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
5k 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
111 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
113 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
79 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/...
2
votes
1answer
423 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
839 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
4k 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
435 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 ...
7
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
580 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
526 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
702 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
81 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
195 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
170 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 ...
1
vote
1answer
733 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
82 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
489 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
110 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
240 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
459 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
132 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 ...
3
votes
3answers
560 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
645 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. ...
2
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 ...
2
votes
2answers
687 views

Bash - Replacing random number between quotes

I've created a script which writes .flame/XML-like files, containing within them, a string which looks like: scale="n" where n is a random number, with a variable number of digits. What I am ...
4
votes
3answers
408 views

Four random words from a list with Perl!

For start, we know how can we output random lines from a txt file: perl -MList::Util -e 'print List::Util::shuffle <>' words.txt But we need a general solution (perl is usually installed on ...
3
votes
4answers
2k views

How can I generate random 64-bit signed integer with macOS?

I need to generate some 64-bit signed integer for testing. How can I do this? #!/bin/sh long=$(????)
-2
votes
1answer
41 views

Generate between interval while having overflow

echo INPUT | MAGIC > OUTPUT INPUT: a random number that can be 0-999999999999 (so very big) OUTPUT: a number between: 0-1023 MAGIC: a solution where the random smaller/bigger input is "converted"...
1
vote
1answer
136 views

How to securely randomize the order of the characters in a string?

[user@notebook ~]$ echo 'aabcd' | sed 's/\(.\)/\1\n/g' | perl -MList::Util -e 'print List::Util::shuffle <>' | perl -pe 's/\n//g'; cdaab[user@notebook ~]$ echo 'aabcd' | sed 's/\(.\)/\1\n/g' | ...
19
votes
5answers
2k views

Variable randomly chosen among three numbers (10, 100, and 1000)

Is it possible to have variable which picks a random number from three pre-decided numbers? Sample: var= 10 or 100 or 1000