In Windows and in Linux, as well as Macintosh, there is something called the HOSTS file, used in an operating system to map hostnames to IP addresses. If left blank by default, it does the automapping for us and generally goes off without a hitch, but depending on how you configure it, it can be used to block ads, to block certain sites, or to redirect us as we search the web. There are many uses for it, and none of them can be said to be foolish. For example, in my HOSTS file under Windows 7, I’m blocking the Windows Live Messenger ads that show up on the bottom of my instant messenger as you can see on the right. For me the ads were enough of an annoyance that I decided to block them outright, and though trial and error, it was possible to find which hosts were providing the ads to WLM. In this case, Wireshark is a godsend, but I’ll touch on it in another post later. If you wish to block or redirect sites, the hosts file is simply the best way to do it.

To modify the HOSTS file in Windows XP though to 7, you can simply open up Notepad and direct your Open dialog to:

C:\Windows\System32\drivers\etc\hosts

An important thing to note is to run Notepad as an administrator in Windows Vista and Windows 7.

To modify the HOSTS file in most Linux distros and Mac OS X, you must open up a terminal and open the HOSTS file as a root user. In the case of Ubuntu and other sudo-based distros, the command would be:

sudo nameoftexteditor /etc/hosts

where you put in the name of the text editor you wish to use. But for Salix and root/user based distros, ‘su’ is used, so the command is instead,

su
nameoftexteditor/etc/hosts

To block a site, simply type 0.0.0.0 sitename or if you’d rather redirect it, you can put in a different IP address in before it, like you can see below.


Note: IP provided for OneMoreLevel.com does not exist at present

The HOSTS file is a very powerful and valuable tool to learn and use, as I use it for force myself to be productive rather then game all the time during school time. Once home, however, that’s quite the different story. I hope this helped some people in resolving what a HOSTS file does and how to use it.

Related posts:

  • About Windows HOSTS File and How To Make Use Of It
  • How Effective is Blocking Websites using HOSTS file?
  • Helpful Sites to Help You Run That One App You Need For Linux
  • Windows and Linux, the same, only different
  • Guide to Install Free SME Server Linux Operating System as File Server