How To Edit Host File. In this article, you will learn why to edit host files, how to edit host files in Windows, how to edit host files in Linux, and how to edit host files in macOS. Host files are the files used by the operating system for mapping the IP addresses to the hostname.
Why To Edit Host Files?
The DNS translates the domain name into IP addresses. This happens when Windows check the host file to see if the domain is mapped. You can edit the host file to map the specific domain names to the IP addresses. You can disallow the DNS from translating the domain names To IP addresses.
You can test your website without the test link. You can check how the site works before DNS changes, block other websites, and other issues related to DNS. After changing the host file, your system directly addresses the IP, that you have set.
How to Edit Host File In Windows 10?
Host files is a text files. It is stored in the system folder of Windows 10. You have to use a text editor to edit the host files. First, you must open the administrator to save the edited host file. If you don’t open it with the administrator, you will be unable to save the edited file. An error stating “You don’t have permission to save in this location. Contact the administrator to obtain permission” will occur. To do so, follow the steps below:
1.Type Notepad in the Windows search bar.
2,Right-click on the Notepad app from the search menu.
3.Select the Run as administrator option.
4.Notepad will now run as an administrator.
5.Click on the File tab.
6.Select the Open option from the pop-up menu.
7.Type or copy-paste the following path in the File name section:
8.Click on Open to open the host file in Notepad.
9.Add the domain name and the IP address you want to use for that domain.
10.Write the IP address first and then add a space.
11.After that add the Domain name.
12.If you want to block a website, route it to the 0.0.1 IP address.
13.Save the file.
14.Restart the computer for the changes to take effect.
How to Edit Host File In Linux?
Follow the steps below to edit the host files in Linux:
1.Press the Super key (Windows key).
2.Click on type Terminal in the search area.
3.Open the Terminal Emulator application from the search results.
4.Type the following command for opening the host file in a text editor:
sudo nano /etc/hosts
5.Make the necessary changes and press the Ctrl + X keys.
6.Enter y, when asked whether you want to save the changes or not.
How to Edit Host File In MacOS?
Follow the steps to edit host files in macOS:
1.Press the Command + Spacebar keys to open the Spotlight.
2.Type Terminal in the search area.
3.Select the Terminal option from the results.
4.In the Terminal window type the following command and press Return.
sudo nano /private/etc/hosts
5.You will have to enter your admin password.
6.After this, the host’s file will open in the Nano editor.
7.By adding the domain name and IP address, edit the file as you want.
8.Press the Ctrl + O keys to save the changes.