Correctly Configure /etc/hosts and /etc/hostname Files


I have laid out a procedure to correctly configure your /etc/hosts and /ect/hostname files.  Improperly configured hsots and hostname files can cuase internet slowdown and even slow down application launching.

What happens in Ubuntu is that a lot of applications accesses the internet.  A while back I was experiencing a terrible internet slowdown and applications took forever to launch.  My windows partitions were still running fast so I knew the cable modem and router were OK.  When I disconnected the cable from my PC then applications launched far quicker.  Ubuntu knew that there was no internet connected so it did not wait at all.  It seems that when in Ubuntu when applications that are lunched access the internet there is a 75 second minimum period of searching for intenet.  I don't profess to be an expert on Ubuntu networking theory but I do know that this procedure works.

By default the /etc/hosts file has way too many parameters.  To edit your hosts file type this in a terminal:

sudo gedit /etc/hosts

The only line your hosts file should have is the following:

127.0.0.1 localhost bob-laptop

I have used bob-laptop for example, replace bob-laptop with your machine's name.  All other line you will need to comment them out.  To comment out a line put a # as the first character in that line.  When done save the file.

Now lets configure the hostname file.  Type the following command in a terminal:

sudo gedit /etc/hostname

This file too should only have one line as well:

bob-laptop

Again replace bob-laptop with the name of your machine.

Again comment out any other lines in this file.  Save and reboot.  Your applications should now launch quickly.  

To help speed up the internet click apply OpenDNS to your setup.  Click here to configure OpenDNS on your machine.

I hope this procedure helps.

 

Home