Guide: How to Edit Hosts File in Mac OS X
- 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 ways to edit the hosts file on a Mac. The most common way is to use the default Text editor feature, which is sufficient for editing a text document. However, 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 back to TextEdit to edit the hosts file on the Mac. ..
/Users/username/.local/share/applications
/ private /etc/hosts is a private file that only the owner of the file can access.
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.
If you want to block a website on your Mac, you can use an edited hosts file. This is a text file that contains the addresses of specific websites. When you open this file, you can enter the IP address of the website you want to block and assign it a host name. In our case, we want to block YouTube. You map www.youtube.com to 0.0.0.0, which will result in an error when someone tries to go to the website. Whenever someone using the Mac tries to go to www.youtube.com, the web browser will not load the page because it is looking for www.youtube.com on 0.0.0.0 instead.] ..
ping www.website.com This will ping the website and print out the IP address.
After making the necessary changes to the Mac’s hosts files, save them to your desktop. Then drag the hosts file 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 then enter the 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 flush the cache and kill the mDNSResponder process: dscacheutil -flushcache; sudo killall -HUP mDNSResponder ..
How to Edit Hosts File in Mac OS X: benefits
Faq
Final note
How to Edit Hosts File in Mac OS X In order to edit the hosts file on a Mac, you first need to open the System Preferences and select the “Hosts” tab. Here, you’ll need to add new entries for every computer on your network. You can also delete entries if you no longer want them on your system. Once you’ve added all of your computers, click on the “Save” button and then close System Preferences. You’ll now be able to access your hosts file from any computer on your network.
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.