Editing your host’s file allow you to override the domain name system (DNS) for any particular domain on a specific machine. DNS management is very handy when you wish to test your own site without making the test link live with SSL.

It, verify that an alias site works perfectly to DNS changes. Editing your host’s file causes your local machine to look directly at the Internet Protocol (IP) address that you specify.

But, users might get confused while editing the host file because it carries from device to device. However, this is the main reason why we are here today. Here in this guide, I will show you the simple steps that you need to follow while editing your hosts file on Windows, Mac, or Linux. So, let start with it.

Also Read- Best Lightweight Antivirus For Windows 10/11

How Do I Edit My Hosts File on Windows, Mac and Linux?

If you want to update or edit your host file on your PC, then simply follow the steps mentioned below:

1.) How to Edit Hosts File in Windows 10, 11, 8.1 & 7

It is a bit complicated to edit the Windows hosts file, but not impossible. So, you can easily do it with our simple guide. You can see steps visually to understand better.

  1. Firstly, go to the Start Menu and search for Notepad and Run it as an Administrator.notepad run as admin
  2. After that, click on the File tab. Then, hit the Open button.
  3. Once done, open the following path: c:\windows\system32\drivers\etc\hosts.
  4. Now select All Files in right below a corner. That’s it. Now, edit your Hosts file as you want.

2.) How to Edit Hosts File in Linux

This method is for people who use Ubuntu or Linux as their daily driver OS. Well, it’s free and open-source. Also, using this, you can edit the Linux hosts file directly in the Terminal. So, here are the steps that you can follow:

  • First of all, open the Terminal Window command line by following the path: Applications > Utilities > Terminal.
  • Now, open the Linux host file by using the Command:
sudo vim /etc/hosts
  • After that, modify the file, use the following command, and also don’t forget to save your file in VIM format before closing the window: server.domain.com

That’s it. Now, if you want, then you can switch your name server. By default, the host file bypasses the standard domain name server lookup. But, another file is there in Linux that notifies the OS about the IP address translations, and that file is nsswitch.conf.

However, if it is set to first lookup the DNS, it’ll automatically skip your hosts file and navigate straight to DNS lookup. Well, to check the configuration, use the command in your Terminal: 

cat /etc/nsswitch.conf

Now, a list of information will be listed. So, make sure that under the Hosts the lists of Files appear first. If not, then use the Command: 

sudo vim /etc/nsswitch.conf

This will open the nsswitch.conf file. So, now you can simply change the Hosts settings to Files appears first and DNS at the end. nsswitch.conf

3.) How to Edit Hosts File in macOS

This is a similar process as you can follow in Ubuntu. Open your favorite GUI text editor, and it is easier to do so from the Terminal also. So, here are the steps that you need to follow: 

  • First of all, open the Mac Terminal. To do so, follow the path: Finder> Applications > Utilities > Terminal.
  • Then, use the following command in your Terminal:
sudo nano /private/etc/hosts
  • Now, your system will prompt a screen asking you to enter a password. So, use the same password that you use to log in.
  • After that, you need to edit your Mac Hosts files. So, make sure that the IP address comes first just before the domain address. However, in a case, while editing it, if you made any mistake, you can use # to tell Mac OS to ignore that Command. server.domain.commacOS (Version) edit hosts file
  • Now, simply save the changes you have made by pressing the Command + O and exit from the window by pressing the Command + X.

So, that’s how you can easily edit your hosts file on Windows, Linux, and Mac OS. We hope this guide helped you. However, in case you have any doubt regarding the topic, feel free to ask us in the comment section.


Please enter your comment!
Please enter your name here