why cannot I edit my `hosts` file?
Usually only the root user is allowed to modify the file hosts.

To do that and fix your hosts file or your /etc folder (depending where you applied your read/write permissions) follow these steps:


Throw away your newly created hosts file (but not the old one!)
Repair your permissions with Disk Utility.

Open Terminal and enter sudo nano /etc/hosts and hit ↵
Enter your password (it will not be shown!) and hit ↵
The standard hosts file in Yosemite looks like this:

Edit your hosts file.
The format for each line is IP-address, then a tab or a single space and the hostname(s). Terminate the file with an empty trailing line.
write the changes to disk with ctrlO followed by ↵
and exit nano with ctrlx
Enter exit, hit ↵ and quit Terminal.app


As an alternative for the steps 3-7 you may download and install hosts.prefpane and enter your additional hosts there.