Javatpoint Logo
Javatpoint Logo

How to Edit Your File on Windows, Linux and MacOS

The host file is often used to link web addresses (hostnames) to IP addresses. It is a data structure that is used for Windows, Linux and mac OS x operating systems. The host file must have precedence over the DNS file. When you enter the web address of the website that you wish to use, the domain name must be converted into the corresponding IP address. The software system first scans its name servers for the corresponding domain and, in the absence of a host submission, asks the specified DNS servers to reconcile the domain name that is identified. Instead of how the domain is treated globally, this only affects the computer on which the change happens.

Using a host file to link a domain to an IP address is especially helpful when you want tovalidate your website without modifying the DNS domain settings. For eg, you want to transfer your website to a different server, and you want to ensure if it is completely functioning before you point the domain to a new server.

You may also use the host name to disable your computer's internet sites.

In this post, we will have guidance on how to change the Linux, MacOS, and Windows host files.

What is a Host file

A Host file is a collection of files that can be used virtually on all devices and operating systems to chart the relationship between an IP address and domain names. This is an ASCII text format. It comprises a space-separated IP address and then a domain name. Each address is given its own rows.

Format of Hosts Files

The Host files contain the following format:

At least one space or tab can distinguish the IP address and domain names.

Lines beginning with # are the feedback and dismissed.

For editing the host file, you need to open the file in a text editor and make the below- given changes.

File updates to hosts would take place automatically, except in situations where DNS entries are cached by applications. To erase the changes, just open the file and delete the lines you've inserted.

Host File Editing in Windows

Host files are used in since ARPANET. They were also used to resolve hostnames in front of the DNS Host archives will be large documents used to help address the name of the network.

Microsoft maintain the host file active in Windows networking, that is why it changes very little when it's found in Windows, MacOS, or Linux. For all portals, the

syntax is probably same. Many host files may have a lot of loopback entries. This can be used for the simple definition of standard syntax.

Host file Editing in Windows 8, 8.1 or 10

Unfortunately, Windows 8 or 10 makes it frustrating to open applications as an administrator - but it's not that hard.

The entire path to the file on Windows is c:\Windows\System32\Drivers\etc\hosts. For editing the host files, you need to follow the above instructions in Windows 8 or 10.

Step 1: Press the Windows key and search for the Notepad into the searching panel. It is shown in the below screen.

How to Edit Your File on Windows, Linux and MacOS

Step 2: Now you'll have to right click the Notepad button and select Run as administrator.

How to Edit Your File on Windows, Linux and MacOS

Step 3: Once you have done, open the following file using the File->Open feature.

How to Edit Your File on Windows, Linux and MacOS

Step 4: After opening the file in Notepad, you can edit the host file.

Step 5: For saving the changes, you need to click on the save option.

Host file Editing in Windows 7

For the host file editing in Windows 7, you can follow the below given instructions.

Step 1: First, you need to open the command prompt, enter the following command and click on the OK to open the file in notepad.

How to Edit Your File on Windows, Linux and MacOS

Step 2: After opening the Notepad, you are required to provide the URL or link of the web page in which you want to make some modifications.

For Example: If you would like to block the Facebook site, then enter the given URL.

Now, enter the link of the specific site after # sign as shown below.

How to Edit Your File on Windows, Linux and MacOS

Setup 3: Now, you can modify the file and save it as displayed in the below screenshot.

How to Edit Your File on Windows, Linux and MacOS

Hosting files Editing in Linux

In Ubuntu 10.04 and other Linux external storage devices, you can modify the domain name explicitly in the terminal. You can use your preferred editor, or you can also open your preferred GUI text file. We'll use VIM for this case.

Like Windows 7, the Ubuntu host file is stored in the /etc / folder, but it is in the root of the drive.

Step1:You need to launch it as a root in order to edit the file, that is why we have used sudo here.

Step 2: Now that, it's available, we can modify it to redirect Facebook to Zero. You will find that there is also a segment for IP6 for Linux. For most uses, you would need to update the top section and skip the IP6.

Step 3: Now, you need to save the file and try going to Much as in screens, we're going to see that we're being routed to a place that doesn't function.

Hosting files Editing in MacOS (Any Version)

For the host file editing in MacOS, you can follow the following steps.

Obtaining the hosts file in MacOS is somewhat similar to Ubuntu.

Step 1: Start from the terminal and use your preferred editor; even if you want to call a GUI text editor, it's easier to do so from the terminal.

Step 2: The directory will appear even more like Windows, but with a little less description. We're going to switch Facebook again.

Step 3: In this way, seems to be a loopback and therefore, will help to lead your mainframes mostly on Apache test page.

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA