Wondering how to edit the host file on your Windows/Linux/Mac machine? The host file is an operating system file that maps domain names to IP addresses. You will not be able to modify it unless you have administrator privileges.
You should not modify the host file if an unauthorized software tool tells you to activate it for a longer period (it usually happens when you download malicious software tools or cracked software). Modifying it for the purpose may not affect your computer, but in some cases, you allow adware programs the ability to deliver you ads while you browse the web.
So, when should you try to edit the host file? To give you some idea, we have mentioned a few situations below:
There might be several more uses to why we need to edit the host file. But, these are the most common situations you would probably encounter. Now that we know why and when do we need it but how do we edit the host file?
Note: The format of editing the host file is same for all platforms (Windows/Linux/Mac). Usually, the IP address comes first and then the host name. “#” sign marks a comment. So, whatever you write after the hash symbol, it would be ignored by the system. For instance, 0.0.0.0 mywebsite.com #onlinepublication (0.0.0.0 is a sample IP address not a real IP).
Editing the host file on any Linux distro is easy. You just need to open the terminal. Usually, you can take the help of the GUI to search for the terminal in the applications or simply press Ctrl + Alt + T.
Now, you just have to type in a command to open and edit the host file (you have to modify it in the terminal itself):
sudo nano /etc/hosts
or vim /etc/hosts
If you want to utilize the GUI, you can try:
sudo -i gedit /etc/hosts
After modifying save the file by pressing Ctrl + X and close it.
Editing the host file on Mac is same as you do on Linux. You just have to navigate your way to find the terminal. To do that, follow the images below:
sudo nano /etc/hosts
to open the host file.If you want to watch a video for a better understanding, we would recommend watching this:
Now that you have known how to edit the host file on Windows, Linux, & Mac, you can do a lot more things when you dive deep on using host file for a variety of purposes. Are you encountering a problem following this article? Let us know in the comments down below.