Monday, December 28, 2009

Change your hostname randomly in Ubuntu

The following script worked great:

#!/bin/bash

#random_computer_name

sudo sed -i 1,10d /etc/hostname

function randnum
{
number=$[ ( $RANDOM % 15 ) + 8 ]
}

randnum

function randpass
{
newhostname=`
}

randpass

(echo '0a'; echo $newhostname; echo '.'; echo 'wq') | sudo ed -s /etc/hostname

sudo /bin/hostname $newhostname


Just add the above script in a file and execute it with "sudo".

To add this file to your startup scripts, just follow the instructions in this post

Source: here

No comments: