Learn to edit Mac hosts file using Terminal.
Getting started, you need to have the administrator account password which you use to log in to the Mac machine.
To edit the Mac hosts file, open Terminal and run the following command
sudo nano /etc/hosts
Here enter the password of your Mac machine to edit your mac’s hosts file
There you have your Mac’s hosts file and add the required code at the bottom like an IP address then leave a tab space and then enter the website address that you would like to block or bypass DNS.
To save the file, press control + X then enter the letter Y and press enter.
You now added the required code to the mac hosts file.
To take the changes into effect, you have to clear the DNS cache. To do that, run the following command.
sudo killall -HUP mDNSResponder followed by the return key or enter.
This will clear your Mac’s DNS cache and prevent any clashes between DNS and the Hosts file.
To remove the website address from the Mac hosts file, open the terminal then type the following command
sudo nano /etc/hosts
Enter the administrator password then remove the address that you would like to and then save the file by typing control + X then Y and press enter.
Finally, you have to clear the DNS by typing
sudo killall -HUP mDNSResponder followed by the return key or enter.
Subscribe to TechEmpty at
Stay Connected with Sai Praveen
Facebook:
Instagram:
Twitter:
Website: