MacOS – Unable to save hosts file after adding websites to block.

hostsmacosterminal

I'm unable to save hosts file after adding websites to block,as well as unable to flush cache. I am not a techie, just researching on the web, and trying to follow directions for terminal and Text Edit.
Did the problem start here (this is how text edit opened):

Host Database

localhost is used to configure the loopback interface
when the system is booting. Do not change this entry.

127.0.0.1 localhost

255.255.255.255 broadcasthost

::1 localhost

It lacked a computer name (I don't have one; this is evident in the System Preferences > Internet and Network Sharing > Computer Name field being empty.) and the "fe80::1%lo0 localhost" line.

"Couldn't Save The file 'hosts' is read=only. Attempt to overwrite?" > Click "Overwrite" > "Couldn't Save Couldn’t save document as “hosts” in folder “etc”.

This is a PowerPC G4 running Tiger (OSX 10.4.11).

Best Answer

This specific request "I want to block sites and need to edit /private/etc/hosts" requires you to know how to edit a normally hidden system configuration file. Your information on an older processor and OS are excellent, but in this case all OS X work the same for modifying the unix host file.

This error is intentional and by design, since making this file easy to modify means that you could easily break the computer from working (and also this file is very desirable for malware or trojan/virus software to attack - imagine if your banking website was directed to another site to harvest your user and password before sending that information to your real bank as part of a "man in the middle" attack.)

Most people use a terminal based editor since it's easily to use the sudo command to temporarily edit the file with root permissions - taking care not to undo the protections that make this not writable by any users directly.

As always, be sure you know how to correct a change like this - the normal Time Machine backup should preserve this file if you know how to to navigate to the /private/etc folder using Finder Go -> Go to Folder... keyboard shortcut before entering Time Machine.