Best 2 Know

The Ultimate Blogging Resource

  • Advertising
  • WebHosting
  • Contact Us
  • Blogger
    • Blogger Templates
    • Blogger Tutorials
  • Browser
    • Firefox
    • Google Chrome
  • Google
  • Internet
    • Facebook
    • Twitter
  • Thesis
  • Windows
  • WordPress
    • WordPress Themes
    • WordPress Plugins
  • More
    • Linux
    • Review
    • Solutions
    • Announcements

How to edit Hosts file on Windows, Mac and Linux

How to Edit hosts fileToday we are going to edit hosts file on our Operating System (Windows, Mac and Linux). In each and every Operating system a host file exists, which is used for mapping an IP address to a Hostname, which is somewhat similar to a DNS server, so I like to call my Hosts file a local DNS server, because it overrides the DNS servers and points to the IP address we provided for the hostname.

What is hosts file ?

hosts file is a Plain Text file that is used by Operating Systems (Windows, Linux, Mac and etc) to map an IP address to an Hostname. It is mostly called hosts but in earlier versions of some Operating Systems it was also named as hosts.txt

How to edit hosts file?

  1. Go to the place where hosts file is placed i.e.
    for Linux and Mac

    /etc/hosts

    and for Windows

    C:\Windows\System32\Drivers\etc\hosts

    Location of hosts file in Windows 8

    Location of hosts file in Windows 8


    for other Operating Systems refer here for locations to hosts file
  2. Open it in your favorite Text Editor (Notepad) and you will see something like this :
    ##
    # Host Database
    #
    # localhost is used to configure the loopback interface
    # when the system is booting.  Do not change this entry.
    ##
    127.0.0.1	localhost
    ::1             localhost 
    
  3. Ignore the Comments (# sign is used for comments in hosts file) and come down to
    127.0.0.1           localhost

    where 127.0.0.1 is the IP Address and localhost is the Hostname, which means that localhost will point to 127.0.0.1 IP Address.

  4. Now lets add a new Entry, go to a new line (by Pressing Enter) and type the IP Address and hostname.
    for me it is this

    198.46.81.165             best2know.info

    The entry is pointing to the new server of Best 2 Know at inMotion Hosting, instead of the old one.

  5. Now just save the file (Ctrl+S)

you can check if the changes are working or not by going to the browser and typing the hostname or by using ping command in Command Prompt, like

ping best2know.info

I would recommend using ping command for testing as you can also view which IP address it is the Hostname pointing to.

Now after learning How to edit hosts file, lets learn its uses.

What are the uses of hosts file ?

Well below are the 2 main reasons I use hosts file.

When I move my Websites to a different Web server or Company.

recently I moved all my websites to inMotion Hosting and after moving files and changing name servers, I had to view whether the website is working properly or not?

At that time Hosts file came into handy and I was able fix all problems before visitors came to the website. it was a simple line in hosts files, that solved the problem.

198.46.81.165             best2know.info

Blocking a Specific website or host

hosts file is also most popularly used to block access to specific site, like to avoid getting caught using a pirated softwares, some people block the Hostname of the Organization that made that software, So the serial key used to register it cannot be detected as a fake.

if you want to block a website, just make map it to 127.0.0.1 IP address i.e.

127.0.0.1       example.com

Do you know some more uses of hosts file, share it with us by using comments

Subscribe via Email

Share this:

  • Click to share on X (Opens in new window) X
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on Pocket (Opens in new window) Pocket
  • Click to print (Opens in new window) Print
  • Click to share on WhatsApp (Opens in new window) WhatsApp
  • Click to email a link to a friend (Opens in new window) Email

Related

September 3, 2014 Ritesh Sanap Linux, Windows hosts, linux, Mac, windows

Leave a ReplyCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Post navigation

Previous Previous post: LastPass – Free Password Manager
Next Next post: Simply Pure – WordPress Theme

Currently Trending

  • How to download Specific parts of YouTube videos
    How to download Specific parts of YouTube videos
  • Windows Vista CD key
    Windows Vista CD key
  • How to retrieve my Demonoid username
    How to retrieve my Demonoid username
  • How to add Logo to Thesis theme
    How to add Logo to Thesis theme
  • How to Delete Feedbacks from JetPack Contact Form
    How to Delete Feedbacks from JetPack Contact Form
  • List Of All 255 Keyboard All Alt Key Codes
    List Of All 255 Keyboard All Alt Key Codes
  • h4x0r ( Hacker ) - Blogger Template
    h4x0r ( Hacker ) - Blogger Template

Get Latest post in your Inbox

Random Posts

Epic Browser – First Indian Browser

July 17, 2010 By Ritesh Sanap 8 Comments

Attribution : New Blogger Widget

May 27, 2010 By Ritesh Sanap 2 Comments

How to add Adsense In between Posts

July 15, 2010 By Ritesh Sanap 3 Comments

Facebook Like or Recommend Button For Blogger

May 24, 2010 By Ritesh Sanap 4 Comments

Make Firefox Work Faster Than Ever

February 29, 2008 By Ritesh Sanap Leave a Comment

WordPress

HTTP2 Server Push for W3 Total Cache Minify plugin

August 17, 2016 By Ritesh Sanap 5 Comments

How to Disable Emojis in WordPress

January 6, 2016 By Ritesh Sanap Leave a Comment

JetPack Related posts and Sharing not working with NGINX

November 10, 2015 By Ritesh Sanap Leave a Comment

Simply Pure – WordPress Theme

November 2, 2014 By Ritesh Sanap 2 Comments

Advanced What should we Write about next? – WordPress Plugin

July 28, 2014 By Ritesh Sanap Leave a Comment

How to Disable Self Pingback or TrackBack

January 16, 2014 By Ritesh Sanap Leave a Comment

BlueStrap – WordPress Theme

January 1, 2014 By Ritesh Sanap 15 Comments

How to Create Multiple Excerpts in WordPress

December 24, 2013 By Ritesh Sanap Leave a Comment

How to Disable Auto Update in WordPress

November 21, 2013 By Ritesh Sanap Leave a Comment

How to Delete Feedbacks from JetPack Contact Form

November 19, 2013 By Ritesh Sanap 9 Comments

Recent Posts

  • HTTP2 Server Push for W3 Total Cache Minify plugin
  • How to show hidden files and folders in Mac OS X
  • How to Disable Emojis in WordPress
  • Canva – Online Photo Editor
  • JetPack Related posts and Sharing not working with NGINX

Archives

Recommends

  • DigitalOcean – Cloud Hosting
  • Dropbox – Cloud Storage
  • Elegant Themes – WordPress Themes
  • LastPass – Password Manager
  • Like us on Facebook
  • Follow on Twitter
  • +1 on Google
  • Subscribe via Email
  • RSS Feed

© 2025 Best 2 Know · All Rights Reserved · We ♥ DigitalOcean