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.
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 inherits administrative privileges to edit and save the hosts file.
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.