Thursday, May 17, 2012

Hosts file : DNS server for local machine

In age of internet , one who does not have domain name , does not have existence. This was line i heard in a movie, Cool as it sounds not really true yet , but eventually may become true.

DNS , Domain Name System , was introduced to identify as machine with a name that one can remember  , and not a machine readble  address like "127.0.0.1" . While its just set of 4 numbers , a name like google.com is always easier to remember than 173.194.36.49. See what I mean ?


 Domain name system works for the whole internet  , But one can make such a thing just for one's computer , This is done by something called a hosts file. Every Operating system has it , usually in a folder called etc , Although this folder can be deep within in your system. but this file does exist.


Lets us see how we can use this file to do things we want to do.


Lets say you want to play a naughty joke on your friend , so when he types in www.yahoo.com , you want him to see google.com , Here is how you can do that.

  1. First you need access to the machine on which you want to play this joke.
  2. Find the hosts file locations are specified below 
    1. Windows
      usually located on C:\windows\System32\drivers\etc\
    2. Mac and Linux
      Usually located in /etc/ folder in root 
  3. Now open the file in administrator privilege
    and now add entries to it so that you can stick yahoo to may be something like google.com
  4. Now save and watch the magic happen
here is a pictographical walkthru

  1. Open hosts file using a text editor , In linux you may have to run this command with sudo

  2. Open the hosts file using the text editor

  3. Now edit the file to map the domain name





  4. Now for the result


Please do comment :)

Any suggestions to make this more easier to understand will be appreciated.









Wednesday, May 16, 2012

Junction : Symblink on windows

Symbolic links are very nice thing with Linux , On windows on the other hand this is not really done so easily , but a tool i came across an year ago which makes things very easy.

It called Junction and is available on this website 
  1. http://technet.microsoft.com/en-us/sysinternals/bb896768.aspx

  2. You have to download this to you machine , I downloaded and extracted it in my c:\Junction folder
  3. Use CMD to get to this directory


     I lookup help on this tool by running /? as a wildcard
  4. Then simply run
    Junction <target directory> <Junction target>



    Now it will show you created and targeted as shown above
  5. Now test it out , by opening the directory

Now you are ready to use the junctions and Symbolic links as per your need :) 

Please do comment :)

Tuesday, May 15, 2012

Virtual Box disk resize



We always run into deadlocks when we need extra space on virtual machines and since the hdd is already created it becomes a problem to re size a disk. lets walk through a fast way of doing so.Using VBoxManage and Gparted

if you find reading as a boring habbit just follow the pictures :)




  1. Open a terminal and CD into your existing virtual disk, the location of the disk can be  found out by using step number
  2. Now create a new disk using
    VBoxManage createhd --filename newone.vdi --size 3000
     Where newone.vdi is the disk name if you see image above you can make anytype of supported image which means this method can also be used for vmware disks
  3. Now copy  contents of the disk which needs to be resize into this one using command
    VBoxManage clonehd packed-disk2.vmdk newone.vdi --existing
    where packed-disk2.vdmk is the original disk (10 gb )
    newone.vdi is the new 30 gb disk
  4. Now open settings of virtual machine in question
  5. Now find the storage controller and the hdd

    this can be used to locate the disk which needs to be resized

    Now change this hdd


    Remember your old disk still remains so if all this effort fails you can always switch back
  6. Now load the gparted iso file in the virtual machine

    Same way the hdd was replaced , but this time choose the cd/dvd controller
  7. Now boot up the virtual machine

    press f12 to get above screen then press c to select cd
  8. Now you will see gparted screen for booting

    select 1st options and press enter
  9. Now gparted shows you some options like keyboard layout , screen resolution , type of card and how to start x server
    my answers were 
    1. Dont touch the keymap
      1. Selected 33 us english
    2. start of the x server automatically
    3. resolution os 1024 X 768
    4. depth 24 bit 
    5. Vesa card
  10. Now you will see desktop , select Gparted icon

    Will give you a screen like this , this point onwards you can right click the partition you want to resize or move and move then. Rules of using Gparted are kinda rigid , but are straightforward
    1. you will have to adjust the partitions according to whats in front and behind the disk
    2. and move them like a puzzle till you get what you want , the disks can be graphically resized
  11. Here is how it looked while processing
  12. Here is how it looked after the partitioning was done
  13. This is how the disk utility looked after i booted my virtual machine

now after this you can either keep the earlier disk or delete it  , If the process goes wrong , then you can always restore you virtual hdd the way it was done in step 5 and you will have restored the hdd


Please do comment :)

Ubuntu 12.04 boot up problems

Ubuntu 12.04 boot up problems on fresh install 
I decided to give ubuntu 12.04 a spin , bought a new laptop recently to try out the power of core i5 , Since ubuntu is one of my most favorite , I decided to dual boot it  like i did with my last one.

Everything went smoothly I installed my games , softwares on the Windows , then went on to install ubuntu with a usb stick , I have no clue what problems Ideapads have with Ubuntu , but the first screen , did not show properly , but having idea of what is there on the boot menu i simply hit enter on the boot menu.


Following this i was greeted by the live cd environment of ubuntu , on which i selected install , so as to install it directly. From this point onwards everything was smooth and fast as usual. Easy selection screens  and the install was complete.

But as soon as i hit restart , the boot loader did not show up , which should have happened automatically. As of writing of this article i have no clue why this happened . This perticular issue did not take place with a full fresh install of ubuntu 12.04 on a desktop done by a friend earlier.

Then i went googling for solution as usual came up with a solution that works , will keep a reference link so you guys can look into that blog post too


This is what i did in steps:

  1. Booted the machine using the Live-CD 
  2. I checked whether 12.04 got installed , did this with help of Live-CD , booted into live cd and started up disk utility and looked for linux partitions on the HDD 

My disk utility screen showed something like above , Now i needed to know which partition root was mounted on , that i got by clicking the right partition with ext format 
  1. From this point on everything was downhill. I
  2. Mounted the partition using
    sudo mount /dev/sda1 /mntsudo mount /dev/sda5 /mnt/boot # this step i did not do I think i did not need it since the boot loader files are installed in the /boot folder of root 
  3. Then simply installed the Grub loader in the boot sector
    sudo grub-install --root-directory=/mnt /dev/sda

/dev/sda is the disk address where the boot manager is going to be installed. This is very important since this will write your MBR to get the boot loader working 

Then i simply rebooted the machine to be greeted by the Grub loader at the start. And thus my experience with 12.04 started 



There seems to be a faster and an easier way of doing the same ,and is available here 
Used commands referenced here