Fun with the hosts file

The hosts file is a file in an operating system that is used to map hostnames to IP addresses. It is a plain text file and can be found in the Windows\System32\drivers\etc\ directory in a windows system and in /etc in Linux. Windows users can simply use notepad to edit it and Linux users can run sudo gedit /etc/hosts to edit it.

When you open the file you might see something like this-

#This is an example of the hosts file localhost
::1 localhost

You can add lines to the file by writing an IP address followed by a hostname. The first line associates the IP address to the hostname localhost. If you enter localhost or into your browser’s address bar, you’ll see an error page unless you have a LAMP(or WAMP in case of windows) server installed. The most common application of the hosts file is that it is used to block websites on a computer.

Now, how do you block a website on your computer? It’s no big deal. All you need to do is add a line to the hosts file. Lets suppose you want to block Facebook. Add the following line to the hosts file-

This will associate the hostname with the IP address and you won’t be able to access the site now. You may also add lines for subdomains like if you wish to block certain subdomains only. Note that you can’t block a certain directory of a website like Blocking a website can be handy at times and very effective if you have only noobs accessing the computer.

Almost every Indian student who has attended computer lab classes in school or at college would have felt bored and jobless at some instance. We all would admit we’ve considered messing with the school/college computers a bit as a cure for our boredom 😛 . I’ve used the hosts file to have my share of fun in my college’s computer lab. We were told that the only website we were allowed to access was Google(read as search engines). I used my jobless mind to experiment around with the hosts file and redirected to a lets say, NSFW website 😀 . Not that I’m suggesting anything (innocently blinking eyes), but if you ever feel like redirecting a domain to some other site, here’s what you need to do:

1. First of all decide the the site to which you want to redirect the site. Now you need to find the IP address for that domain. Note that if the site is hosted on a shared host, it won’t have a dedicated IP address associated with it. So its always a good idea to pick a famous website that is more likely to be on a dedicated server. Lets take the example of facebook for instance. Suppose I want to redirect to facebook. Use any online service to get the IP address for You’ll get This is the IP address you want to redirect the hostname to.

2. Add a line for the IP and the hostname you want to redirect to the hosts file. In this case, it would be Mischief managed, you’re done.

Needless to say, try stuff at your own risk and stay out of trouble at school/college. There was one more occasion when I used the hosts file in college. We were supposed to launch the website for Technosearch 2011 on the stage and we had no internet access there. I used the hosts file to point to to make the launch look better. Hope this post helped you understand the purpose of the hosts file better and helps you use it for your work.

Changing Bootup Resolution (Plymouth) in Ubuntu 10.04 Lucid Lynx

I’ve written a post on adjusting the bootup resolution i.e. the resolution of the splash screen that shows up when you start Ubuntu. Lots of things have changed since then. GRUB2 has replaced GRUB as the default bootloader and Plymouth has replaced Usplash so although changing the bootup resolution has a similar procedure, its a bit more complicated with GRUB2 and Plymouth.

Why would you want to change the bootup resolution? People are complaining that the ubuntu logo in the startup splash screen has turned large and ugly after installing ATI or Nvidia propitiatory divers. That is because the bootup resolution is too low. Other people might not be able to see the splash screen at all. In short, if you have any issue related to the splash screen not showing up properly, you are recommended to try this procedure. This is what the splash screen would normally look like(click to view full size)-

Ubuntu 10.04 Lucid Lynx Splash Screen
Nice and Purple: The Ubuntu 10.04 Lucid Lynx Splash Screen

Note- In this procedure, I’ve assumed that your monitor supports a resolution of 1280×1024 and used this resolution in the steps. If you have an old monitor, it is possible that it might support a maximum resolution of 1024×768. You are free to try any resolution your monitor supports. If its a widescreen, you might want to try widescreen resolutions as well. Any resolution would work as long as your monitor supports it. And for those who think its not obvious, when I write ‘run ‘ it means you need to run it in a terminal.

Here’s how to change the bootup resolution and fix the big, low-res Plymouth logo-

1. First of all, run sudo apt-get install v86d in a terminal to install the v86d package.

2. Now you need to edit the resolutions in the GRUB2 files so run sudo gedit /etc/default/grub and look for the line-


and replace it with-

GRUB_CMDLINE_LINUX_DEFAULT=”quiet splash nomodeset video=uvesafb:mode_option=1280×1024-24,mtrr=3,scroll=ywrap”

Then look for-


and replace it with-


Note that you need to remove the # from the beginning of the GRUB_GFXMODE line else it will be commented out. Also, I repeat, you may use any resolution you wish to use in place of 1280×1024 as long as your monitor supports it. Save the file and close the text editor.

3. Now you need to edit another file, so run sudo gedit /etc/initramfs-tools/modules and add the following line at the end of the file-

uvesafb mode_option=1280×1024-24 mtrr=3 scroll=ywrap

Don’t forget you need to replace 1280×1024 if you used some other resolution in the last step. Save the file and close the text editor.

4. Now run echo FRAMEBUFFER=y | sudo tee /etc/initramfs-tools/conf.d/splash
You’ll get FRAMEBUFFER=y as output.

5. Now run sudo update-grub2
This will generate the updated grub.cfg file.

6. The last step is generating the new splash screen. To do that, just run sudo update-initramfs -u

Now reboot Ubuntu and you should see a much better looking, high resolution splash screen and GRUB menu. If you see nothing at all, it might be because your monitor does not support the resolution you set. Try a lower resolution in that case.

Changing Window Button Positions In Ubuntu

People who upgraded to Ubuntu 10.04 would’ve noticed that the new Ambiance theme has window buttons on the left side of the window border. This means, when you install Ubuntu, you get an unordered set of buttons on the left which look like this-

Unordered buttons on the left
Unordered buttons on the left side spells DISASTER

At first sight, it doesn’t seem to be much of a problem to have the window buttons on the left. But it gets really irritating when you start using it and tend to move your mouse pointer towards the top right to find absolutely no buttons there. I tried living with it for a couple of hours before I finally gave up. Its pointless to get used to working with the window buttons on the left. You’ll go crazy when you’ll have to work on other computers in your office/labs with buttons on the right. So its highly recommended to change the position of the Window button and bring them back to the right side. Doing this is pretty simple.

1. Open the GNOME Configuration Editor. There are many ways to do this like typing ‘gconf-editor’ in the terminal.

2. Move to ‘/apps/metacity/general’ and edit the ‘button_layout’ key.

3. Set the ‘button_layout’ key to ‘menu:minimize,maximize,close’ as shown-

Ordered Buttons
Edit the button_layout key to change the button position to right as shown.

The buttons mentioned before the colon appear on the left and after the colon appear on the right. Your buttons will now be on the right side of the window border.

If you still didn’t get it, here’s a video tutorial explaining how to do this-

Ankur suggested me a simple python script that uses a GUI to change the button position on the fly. You can check that out if you’re more of a GUI person.

Domain + Unlimited Hosting for $10

This is a Sponsored Post written by me on behalf of Nexx Inc. All opinions are 100% mine.

Nexx web hosting has been re-branded and to promote the new launch, they are having a special promotion where they are offering free Unlimited Web Hosting and a free .com domain for 1 year at the approximate price of a .com domain- $10.


Here are the features of the hosting plan-

  • Diskspace: Unlimited
  • Bandwidth: Unlimited
  • E-mail: Unlimited
  • Free Domains: 1
  • 24/7 Customer Support
  • Google Adwords Credits: $50
  • Facebook Ads Credits: $50
  • One-Click WordPress and Blog installations

Its a really good offer and is worth trying. All you’ll have to spend in the first year is $10 which amounts to a saving of $61.40. If you have an idea but aren’t willing to invest too much on hosting yet, you can take advantage of this offer, make a website. Then monetize from it for a year. If it is able to recover the cost and generate enough revenue to support future hosting costs, continue with it. Otherwise, you can always drop the idea after trying for a year. One year is also a good enough time period to judge the host in terms of uptime, customer support etc. This really is a smart promotion and its a win-win situation for the clients. You can always judge a host and move your site to another host if you are unsatisfied. So, in short, this promotion really is worth trying.

Visit my sponsor: Unlimited Web Hosting + Domain Name for $10 @ Nexx

Canonical URL by SEO No Duplicate WordPress Plugin