SRANDOM is a more random replacement for the not so random RANDOM. It can be SRANDOM was released first time, on end of 2020. Additional, the SRANDOM can used for a bigger range of counts than RANDOM. SRANDOM comes with Bash-5.1.

So its the question, how to update to bash 5.1 or gettin SRANDOM support by other way ?


  • 16-bit
  • create data which are not so equally distributed


What need to be installed or updated to make SRANDOM available on konsole of Ubuntu and how to install or update ?

And as an alternate for systems, which dont run bash 5.1 in future too, how to get and run the C code from SRANDOM implimentation in a bash script or on terminal ?

  • Can you wait 2 months? It seems bash 5.1 is in Ubuntu 21.04 (See this.) You can try installing it earlier, but I worry that it'll be fairly difficult given the potential number of dependencies...
    – Ray
    Feb 24, 2021 at 6:58
  • @Ray, and as an allternate for systems, which dont run bash 5.1 in future too, how to get and run the C code from SRANDOM implimentation in a bash script ?
    – Eddy763
    Feb 24, 2021 at 7:37
  • I don't believe the SRANDOM variable in Bash 5.1 has anything to do with the /dev/srandom kernel module ... Jul 21, 2021 at 9:00
  • Nor does it have anything to do with the srandom() function. So you're basically mixing 3 different things with the same name together. Jul 21, 2021 at 9:09

2 Answers 2


The source-code for SRANDOM is available here https://github.com/josenk/srandom and you should be able to install on Linux with kernel 3.10 or above.


If you are into development or devops, you will probably have them already.

sudo apt install git make 


The the source

mkdir your-srandom-source-code-dir
cd your-srandom-source-code-dir
git init
git clone https://github.com/josenk/srandom


The combo manual listed here https://github.com/josenk/srandom#compile-and-installation - but a brief example including installing a pre-requisite package:

sudo apt update && sudo apt install kernel-devel

cd your-srandom-source-code-dir
make install


You use SRANDOM as if it was an infinite file full of the desired random data, so for example, you can use it as a data-source for dd. But avoid using commands which don't limit the amount of data they read (like "cat"), as this can cause performance issues.

dd if=/dev/srandom count=1 bs=1M of=random-output.txt
  • Would be neat if you explained your downvote... Jul 22, 2021 at 14:36

On systems which still dont support SRANDOM, you can use the follow, as better alternate to RANDOM, until your system supports SRANDOM:

rnd="$((0x$(dd if=/dev/urandom of=/dev/stdout bs=4 count=1 status=none | xxd -p)))"

A it can be, SRANDOM will be faster.

One othe alternate are:

my_rnd=$(openssl rand 4 | od -DAn)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.