Text file hosts — little known, but very important thing. It contains valuable information for going online — database of domain names and used when they are translated into the network addresses of nodes.
Sometimes you need to make some changes. How to do it?
Advanced users make edits to hosts through OS X Terminal. But for those, who prefers to use a more familiar graphical interface, there is another way — editing through text editor TextEdit.
Required note: without need and without proper knowledge in hosts it is better not to change anything. Incorrectly formatted file can cause problems with DNS servers and make it impossible to visit certain sites.
If you work with OS X 10.11 El Capitan or a newer version of the system, first we will have to disable the new protection from Apple called System Integrity Protection (SIP).
- Restart your Mac and hold the Command key (⌘) + R. It will load into safe mode.
- On the menu bar, select Utilities, then Terminal.
- Enter the following command in the Terminal: csrutil disable; reboot
- Press Return (Enter).
- You will see a message about, that System Integrity Protection is disabled, and to accept Mac changes, a reboot is required, which will happen right away.
To check the status of SIP (on or off), open a terminal and enter the following command: csrutil statusIf done correctly, The word Terminal will appear in the Terminal’s response (is disabled). Enabled (included) means, that something went wrong.
Now you can begin to edit the hosts file. For this:
- Close the TextEdit application, if it is open.
- Open Terminal. The easiest way to do it — enter the word «Terminal» in spotlight search (icon with a magnifying glass in the upper right corner).
- Copy the following command to the Terminal command line: sudo open -a TextEdit /etc/hosts
- Press Return (Enter). If necessary, enter the administrator password.
- The hosts file will open in TextEdit. Make the necessary changes and save them via the menu bar (File —> Save) or the keyboard command Command (⌘) + S. Next, close TextEdit first, then Terminal.