LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - News > Syndicated Linux News
User Name
Password
Syndicated Linux News This forum is for the discussion of Syndicated Linux News stories.

Notices


Reply
  Search this Thread
Old 04-18-2019, 11:22 AM   #1
LXer
LXer NewsBot
 
Registered: Dec 2005
Posts: 128,370

Rep: Reputation: 118Reputation: 118
LXer: How to Generate a Random Number in Linux


Published at LXer:

How to generate a random number from the Linux command line. We will explore how to generate a random number within a range and also a specific length.

Read More...
 
Old 04-18-2019, 11:47 AM   #2
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
Code:
cat /dev/urandom | base64 | head -c 64
 
Old 04-18-2019, 12:35 PM   #3
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
Quote:
Originally Posted by szboardstretcher View Post
Code:
cat /dev/urandom | base64 | head -c 64
Thank you.
I was reading the linked article and was about to suggest that you do the same when I got to the end and realised that, nowhere, had they mentioned the true randomness of the numbers. Your method could be used with a true random number generator or, at least, something like the sound-based one to create the least-predictable numbers your system is capable of.
 
Old 04-18-2019, 12:47 PM   #4
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
Right on!

If you get into a situation where you need 'more' randomness, you can hit up random.org via http or api. They use atmospheric wash to create random readings.

random.org

For more information.
 
Old 04-18-2019, 01:10 PM   #5
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
I'll be honest in that my interest in random, aside from the odd SSH session, is just curiosity. It did occur to me just now, however, that I've a couple of USB SDR devices which ought to be able to find something actually random?
I seem to recall the sound-based one is randomsound?
 
Old 04-18-2019, 01:13 PM   #6
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
Sure. But sound isn't as random as might be expected. After a while you will get repetitions in your singular environment. Ie: you sneeze every 4m, heater kicks on 3 times an hour, etc. There are recurring sounds and reasons that your random feed would be psuedo-random or not-random.

I made a random generator years ago that:

Grabbed the news headline of the moment
Converted all the letters to numbers
Grabbed a random subsection of weather data
Converted all the entries to numbers
Did some math on the results and converted to base64

That got me a lot of good random data to mess around with at the time. Not sure I'd do it the same now.

Last edited by szboardstretcher; 04-18-2019 at 01:15 PM.
 
Old 04-18-2019, 01:20 PM   #7
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
I admit I don't know how randomsound works, but I suspect the developers weren't that stupid? Perhaps?
To be fair though, up until now, only stupid "random" systems seem to have been broken.
 
Old 04-18-2019, 01:25 PM   #8
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
We are all only human. Remember when Debian broke OpenSSL randomness which no one noticed for years? https://www.schneier.com/blog/archiv..._number_b.html
 
Old 04-18-2019, 01:36 PM   #9
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
Have to admit I dobn't recall that exactly but have read of similar over the years.
Perhaps there's a "Schneier's Law" stating that even the best crypto syystem will fall to implementation eventually?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Generate a random number from a bourne shell script lothario Linux - Software 2 03-01-2007 11:01 PM
pls help on how i can generate 4 digit random number that are unique within the set icylicious Programming 7 08-22-2006 01:00 PM
Generate random number with C++ TruongAn Programming 5 11-09-2005 12:01 AM
Python problems trying to generate a random number davholla Programming 0 10-27-2003 04:07 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - News > Syndicated Linux News

All times are GMT -5. The time now is 10:26 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration