How to edit hosts file :Windows xp/vista/7/8 Ubuntu Mac

Hosts file is something like a directory service. It maps ip address with the corresponding websites. As the incorrect phone number entry against a name puts your call to the wrong person, similarly a incorrect ip address entry against a website will land you on wrong website.

Thus when you manipulate this hosts file entry you can redirect users to different website or simply a non existing ip address.

You will need to remove the Read Only parameter of the hosts file first. You can do this by right clicking the file -> properties -> uncheck read-only attribute.

edit hosts file.
How to Edit Hosts File.

The method of editing the hosts file varies for different operating system lets check it one by one.

Windows 8 or 8.1 :

Log in as administrator. Open Windows File Explorer and go to c:\windows\system32\drivers\etc\ Right click hosts file and click open with notepad. If asked to ‘Run as Administrator’ click OK to continue.

Windows Xp/Vista/7 :

In windows 7 you will need to open the hosts file through notepad. So open Run and Type:

notepad c:\windows\system32\drivers\etc\hosts

Notepad inherits administrative privileges to edit and save the hosts file.

edit hosts file.
Hosts file.

Ubuntu :

In most of the Linux distros the procedure to edit hosts file remains the same. The file is located /etc/ folder. To edit and save file you need to have root privileges so you need to use sudo. The file can be edited in the terminal itself. Type the command in the terminal to edit hosts file :

user@ubuntu:~$ sudo vim /etc/hosts

Mac OS :

You can edit the hosts file using any editor of your choice if you want to edit the file using GUI else the procedure remains same as in case of Ubuntu.

Changes to be made to hosts file:

Point the ip address 0.0.0.0 which does not exist to the domain you don’t want to display. You can similarly divert a website to display your company’s website by entering the server’s ip address.

When you edit hosts file be sure of what you are doing. Be careful while editing system files.

Related Posts:

Leave a Comment

Your email address will not be published. Required fields are marked *

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