Search this blog

Monday, September 30, 2013

using bash to generate random numbers

I did not know it but it was fun to discover: you can use bash to generate random numbers 
/dev/random and /dev/urandom generate random strings. 
(you can read more about it here and here).

Some examples of the foolish play i found myself engulfed in:
[gil@XXX ~]$ head -1 /dev/random  

[gil@XXX ~]$ echo $RANDOM                         

[gil@XXX ~]$ echo $RANDOM    

[gil@XXX ~]$ echo $RANDOM       

[gil@XXX ~]$ echo $((RANDOM%200-100))

[gil@XXX ~]$ echo $((RANDOM%200-100))

[gil@XXX ~]$ echo $((RANDOM%200-100))

[gil@XXX ~]$ echo $((RANDOM%200-100))

[gil@XXX ~]$ echo $((RANDOM%200-100))

[gil@XXX ~]$ echo $((RANDOM%200))

[gil@XXX ~]$ echo $((RANDOM%200))

[gil@XXX ~]$ echo $((RANDOM%200))

[gil@XXX ~]$ echo $((RANDOM%200))

gil@XXX ~]$ od -An -N2 -i /dev/urandom   

[gil@XXX ~]$ od -An -N2 -i /dev/urandom         

my source for this lovely discovery - Bash Shell Generate Random Numbers.

Sunday, September 29, 2013

Oracle tidbits: IN vs. EXISTS and more...

As I was trying to recall how does oracle execute a correlated subquery I ran into several discussions by tom kyte about in, exists, and more ... 

Not every day you get a chance to see a discussion spanning more than 12 years, exemplifying how the development of the Oracle Optimizer changes technical answers over time... 

Tuesday, September 3, 2013

installing a virtual linux guest: CentOS on VirtualBox

I've been asked on occasion to guide/assist/point/encourage/support/whatever in the process of installing a virtual linux guest. 

Finding myself doing some installations following a sad incident , I thought i might use the enforced opportunity to document my steps (to some extent, and not too deep a resolution), and provide a post which may interest some. 

So, here it is - a play-by-play description of the process of installing a centos 6.4 as a guest on a windows7 host. 

=getting the stuff=
download virtual box

the downlodas area:
the user manual:

download centos 6.4
i did it from
and chose an iso

Accessing the iso
the most convenient way, in my mind, is to access iso files with the kind help of a virtual dvd-drive. my preferred option for windows being the free virtual clone drive provided by slysoft which can be downloaded here

(btw, my preferred option for linux is currently cdemu. for those who can benefit from an installation guide, last time I installed cdemu (on a linux mint 15 trial), this one was beneficial for me).

=installing the guest machine=
having all this around- 
  •  install virtual box 
  • create a virtual machine (haven't seen real differences, but i opt for a "red hat" type when I install CentOS)
  • mount the centos iso using your virtual drive software. 
  • run the machine 
  • upon its run, choose to boot from the virtual drive where the iso resides. 
  • and now - install centos with the polite help of the centos installation wizard 

=installing guest additions=
to install guest machines, virtual box requires dkms
centos doesn't have it in its regular repositories, and for this reason we need the excellent rpmforge repository. I wrote in the past a short howto.  So - 
  • setup rpmforge. 
  • Afterwards, do a "yum install dkms". (As yum will tell you, dkms brings along several friends, from the CentOS repositories. Have no fear - they are all helpful). 
  • Now, Choose from the virtual-box interface: Devices \Install guest additions, provide the necessary feedback to auto-run the guest-additions installer.
And.... voilĂ , you have a virtual machine running a linux guest !

  1. in 64bit sometimes the dependencies installed with dkms might not be the ones Guest additions shall require. Guest addition also relies on kernel-devel, and I've experienced on occasion situations where /usr/src/kernels/[kernel version]/build was a dead link, and remained thus despite all attempts to bring the relevant packages. the result was that virtual box guest additions step of "building the main guest additions module" kept failing with the log referring to the dead link. the solution was yum install kernel-devel-xxx (where xxx stands for the full version name; in the last instance this was: 2.6.32-358.el6-x86_64, hence the command that saved the day: yum install kernel-devel-2.6.32-358.el6-x86_64
  2. I've been meaning to make a step-by-step installation guide, as I know some may greatly benefit from it. But it is so tedious, that usually at one step or another one just tires and goes for the more generalized style of guide. If there will be enough demand - I promise I'll make one. One day.