Whenever you want to control all the websites or traffic on your computer, you need to add the DNS on the hosts file. For this reason, you need to know how to edit hosts file on Mac or Mac OS X. The host file on the OS will help you to control the overall website if you will access it or not.
In general, Hosts File refers to a file which determines which website you want to browse or not. By default, it gives access to all sites around the world. But if you want to customize it, you need to edit the hosts file on Mac.
How does the Hosts File Work:
When you are browsing a website on your PC, you can’t see something which is happening in the behind. Every Digital Devices has a unique TCP or IP Address. With this in mind, the website has also a unique numeric address. How will you remember this complicated numeric address for visiting it? For this reason, DNS (Domain Name System) work as a translator to convert that numeric digit into a human rememberable name.
That means it works as like Web Address>DNS Server>TCP/IP Address>The Results. To clarify, when you are trying to visit a website, it will find out the DNS server of that website. Then the DNS gives the location of TCP or IP Address. Then you get the results. Though all the process happens automatically. For this reason, you can’t understand it. If you visit the website later from the same PC, the Mac or PC can keep the cache of the command. So, it can show you the results fastly than the first time.
Now, What does Host File Do on Mac?
Basically, when you want to edit the host file, you want to block or control the website, if you can access or not. In general, you are doing it to tell your computer not to follow the website’s DNS or TCP. That means it will not show you the sites. On the other hand, the hosts file have some other uses with the DNS and IP Address. Here we will learn only how you can edit the hosts files on Mac OS X.
How to Edit the Hosts File On Mac OS:
The best way to keep away a website from your Mac OS is adding the IP Adress to the hosts file. It will It will disappear in your Mac before updating it again. With this in mind, we try to work on editing the hosts file. The best way to edit the host file is working the Terminal.
Check Out Also: Hosts File Location Of Mac OS
Step 01: Open The Hosts File
i. Firstly, launch run the Launcher (F4 Key) and search here by typing Terminal. Now access the Terminal. You can also get it by Finder>Applications>Utilities>Terminal
ii) Now, we’ll work with the nano text editor for opening the hosts file on Mac. For opening the Nano Text Editor, you have to type a command on the terminal. Then it will take the administrator password of your Mac OS.
- For Opening Nano Text Editor type “sudo nano /etc/hosts” and then hit return
- Now give the administrative password and again hit return. Now you are in the Nano Text Editor. You have to work here for editing the hosts file on Mac OS.
Step 02: Editing Hosts File On Mac
Here you have to add the hosts file to keep away any other website form your Mac. If you want to add new websites follow the below instructions.
- Use arrow key to bring the cursor in below of the hosts file.
- Give the IP address and Domain Name here. The Format will be like the below.
- When you will finish editing the hosts file on Mac, you have to give the command Control+O to save and at last give Control+X to exit the Nano Text Editor.
Step 03: Flushing DNS Cache (Optional)
You have completed the process of editing the hosts file. One more step to ensure it is working. Sometimes, it takes time to functions of your task on hosts file. For this reason, you need to work with the flush the DNS cache. For doing this follow the below command.
- Type “sudo killall -HUP mDNSResponder” on the command line and hit return. It will help to work the process and realizing the PC instantly.
Note: Always remember the changes and what you have edited the hosts file on your Mac. You may need to update it again. On the other hand, you may need to work here again.
Editors Note From TechyPi:
At last, I think you have realized the tutorial of editing the hosts file on Mac. I have done it my Mac OS. So you should not have any problem. If you face any problem, you can place a comment from the comment section.
At the same time, if you get the article helpful, express your love by sharing it on your social media. All the best wishes.