Hosts file is like an address book where you’re given the control to block a handful of websites, restrict advertisement from appearing on webpages, and exclude objectionable content found on the Internet.
Editing and duplicating the entries of hosts file on Mac OS X 10.7 Lion and Snow Leopard machine is as easy as editing on Windows platform.
However, with the stable Mac OS X Lion, Apple just got a little smarter in restricting access to hosts file.
Even though if you are the admin of your Mac, you are not able to save the original hosts file located at /etc/hosts.
Unlock Hosts File?
Whether you are using an iMac, MacBook Air, or MacBook Pro, there’s no easy solution to unlock the locked hosts file. If you duplicate hosts file, you’ll probably end up with another version of hosts file, which acts no more than just a backup of the original hosts file.
Some of the errors encountered while dabbling with the hosts file are as follows:
The file hosts cannot be unlocked. You can duplicate this document and edit the duplicate.
You don’t own the file hosts and don’t have permission to write to it. You can duplicate this document and edit the duplicate. Only the duplicate will include your changes.
Terminal comes to the rescue if you want to manually edit the hosts file, even if the file is locked.
Steps to edit locked hosts file on Mac OS X Lion:
- Go to Spotlight and launch Terminal by typing in the keyword Terminal. You can also find Terminal under Applications -> Utilities -> Terminal.
- Now type this command in the Terminal screen: sudo nano /etc/hosts
- Terminal will prompt for your Mac’s admin password. Enter the password and you’ll be able to edit the hosts file.
- Once you’ve done editing the hosts file, hit the CTRL+X keys and then press Y (yes) to confirm and save the changes.