Adding hosts to windows and linux
Using hostnames is an easier way to remember about one’s server rather than using it’s ip, like localhost for 127.0.0.1, etc.
To add the hostname in windows, we have to edit the “hosts” file present in the etc folder in both windows and linux. In windows, it is present in :
and in Linux it is present in :
To edit the file,
In windows, open notepad or any other text editors in administrator mode, i.e. right click the shortcut and click “Run as administrator” and open hosts file present in the aforementioned path and add the hostname as per instructed in the file or as below :
Add as much as required, save the file and close it.
In Linux, run the following command
sudo vim /etc/hosts
and enter your password. Press “i” to edit the file and add the statement as above. i.e.
Press “ esc” and type in “:wq”to save and quit the document.