Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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).

share|improve this question
add comment

2 Answers 2

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.

share|improve this answer
add comment

If you want to have your computer to have a name for networking purposes just enter one in System Preferences > Internet and Network Sharing > Computer Name.

That's what I would recommend, because Apple OS X is mostly configured using Apple's GUI and not like other conventional Unices editing text files manually. Most of the time the manual edits will be overwritten.

Generally speaking if you want to edit system files I use the terminal most of the time. To get system privileges to be bake to save those files I use sudo, which precedes commands to execute the command with system privileges. Using sudo you have to type in your password to get access and you have to be an administrator.

An fairly easy to use command line editor would be nano, which belongs to OS X by default.

Editing the hosts file would be:

sudo nano /etc/hosts

You have to use control and not command keys to use nano. control+x would exit the editor. If you want to save your document, just answer y at the following prompt.

Further help in nano is displayed at the bottom of the screen.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.