Guide: How to Edit Hosts File in Mac OS X

  1. Open the Terminal application and type the following command to open the Mac hosts file: /opt/macosx/bin/hosts

Edit Mac Hosts file with edit text

There are a number of different ways to edit the hosts file in Mac OS X. One method is to use the default Text editor feature for editing Mac host files. Since the Mac hosts file is a text document, using TextEdit is a sufficient tool as a Mac hosts file editor. But it is important to note that TextEdit cannot open the file directly and you must copy the file to an unprotected location such as the desktop, edit it and then copy it to TextEdit to edit the hosts file on the Mac .

/private/var/db/hosts To find the hosts file, open Finder and select from Finder’s menu bar Go> Go to Folder. Type the following location in the box and press Return. You can find the hosts file in your Mac’s private folder, which is located at: /private/var/db/. ..

Private hosts, such as those used by businesses and organizations, are not generally accessible to the public. ..

A new Finder window will open and your Mac’s hosts file will be selected. Click and drag it out of the Finder window and drop it on your desktop. This allows us to freely edit the file. ..

To open the Mac hosts file, just double-click and the contents of the file will be displayed in TextEdit. By default, the hosts file is simple, as it contains only a few lines of descriptive text “commented out” with the hash or hash (#) sign. The host file also has IP values ​​for localhost and broadcast host. To edit the file, add your own rules after broadcast host.

To block access to a website on your Mac, you will need to create an edited hosts file. This file will list all of the websites that your computer should not be able to access. You can map any website to a specific IP address, and then assign that IP address to the host name associated with that website. For example, if you want to block YouTube, you would add the following line to your hosts file: 0.0.0.0 www.youtube.com

ping www.website.com This will ping the website and print out the IP address.

After the changes are made to the hosts files on the Mac, save them to ~/Desktop/hosts. Then drag the ~/Desktop/hosts file from your desktop back to its original location / private / etc.. If the Finder window is closed, use the Finder> Go> Go to Folder command, to reopen it.

OS X will ask you what to do with the unmodified hosts file that is already there. Choose “Replace” and enter your administrator password to authenticate the transfer. ..

sudo -u Yosemite -p /Applications/Yosemite.app/Contents/MacOS/System Preferences/DNS For OS X Mavericks and Yosemite, open Terminal and use the following command. Note that you will need to enter your administrator password to run it: sudo -u Mavericks -p /Applications/Mavericks.app/Contents/MacOS/System Preferences/DNS

This command kills the mDNSResponder service on the system.

sudo defaults write /Library/Preferences/com.apple.LaunchServices.plist To open the System Preferences window, type “System Preferences” in the Spotlight search bar and press Enter. Click on the “Security & Privacy” icon. In the window that opens, click on the “General” tab and then type “sudo” in the “Command” field. Click on the “OK” button to save your changes and close the window. ..

Dscacheutil -flushcache; sudo killall -HUP mDNSResponder

How to Edit Hosts File in Mac OS X: benefits

Faq

Final note

This guide will show you how to edit the hosts file in Mac OS X. This file is used to resolve hostnames and IP addresses. If you have any questions or concerns about editing this file, please feel free to ask us in the comments section below. Additionally, please share this guide with your friends so that they can learn how to edit the hosts file as well. ..

If you have any queries about the How to Edit Hosts File in Mac OS X, then please ask us through the comment section below or directly contact us. If you want to correct any misinformation about the guide, then kindly contact us.