Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Nermal

Moderator
Staff member
Dec 7, 2002
20,646
4,048
New Zealand
The link you posted has the right method, although I prefer pico over nano (personal preference, though). Shouldn't pose any problems.

In a default install, pico is symlinked to nano anyway so it won't really matter unless internaliserad has manually installed pico :)
 

Mal

macrumors 603
Jan 6, 2002
6,252
18
Orlando
In a default install, pico is symlinked to nano anyway so it won't really matter unless internaliserad has manually installed pico :)

Oh. NM. I'm not really a UNIX expert overall, I just offer what I do know. Now I know a little bit more.

jW
 

internaliserad

macrumors newbie
Sep 17, 2012
3
0
Your first command will open it, but you won't be able to save it. BTW, "sudo open -t /etc/hosts" would do the same thing much quicker.

The link you posted has the right method, although I prefer pico over nano (personal preference, though). Shouldn't pose any problems.

jW

Thanks for quick reply, really helpful!

Went In to the Mac store a couple of days ago and asked about this and why I no longer ( on the new system ) was able to access my private folder ( where the hosts file is ) and this guy...i tell you, he just told me that I had nothing to to there... got a little bit irritated but anyways Thanks a lot!
 

macnewlover

macrumors newbie
Oct 13, 2012
1
0
What file name to save?

EDIT:
Got it! I had to use:
Code:

sudo nano /private/etc/hosts

to edit the hosts file within Terminal, Control-O to save, then hit the Return key and I was golden and ready to go.

Thanks alot to all guys sharing here. It works. Just one question: Which file name I should save? I saved the same file name "/private/etc/hosts". Am I right?
 

gurdjiev

macrumors newbie
Nov 28, 2012
4
0
Thanks alot to all guys sharing here. It works. Just one question: Which file name I should save? I saved the same file name "/private/etc/hosts". Am I right?

Did you open your file to see if the changes were saved?

Here's the solution I just found. A small application called Gas Mask:

http://www.macupdate.com/app/mac/29949/gas-mask

Launch Gas Mask and it opens the hosts file automatically. Type in the changes (or copy and paste), save, and its done. Close file and reopen and you will see the saved changes.

I spent a lot of time trying to learn Unix code to operate Terminal and used the sudo and pico commands, but wasn't able to save changes to the file, (only as a backup text file) because I, as the admin, didn't have permission to write the file. Spent a lot of time trying to change permissions but to no avail. Try Gas Mask if you're having the same problem. Thanks to nudoru for this software solution.
 
Last edited:

thejerryong

macrumors newbie
Feb 11, 2013
4
0
Manila, Philippines
Finished Repairing Disk Permissions, then Verified Disk Permissions, and Restarted. Still cannot unlock the hosts file.

EDIT:
Got it! I had to use:
Code:
sudo nano /private/etc/hosts
to edit the hosts file within Terminal, Control-O to save, then hit the Return key and I was golden and ready to go.

Thanks for trying to help, I hope someone else gets use out of this thread :)

Thank you for this. I have successfully edited the hosts file. But there's only 1 problem occurred after I edited the hosts file, I cannot access http://www.adobe.com anymore.

Any ideas on how to solve this problem? Thank you
 

helios16v

macrumors regular
Original poster
Nov 1, 2008
149
0
Earth
Thank you for this. I have successfully edited the hosts file. But there's only 1 problem occurred after I edited the hosts file, I cannot access http://www.adobe.com anymore.

Any ideas on how to solve this problem? Thank you

Use a VPN switcher? I wanted Google Music in Canada but it won't allow you to subscribe in Canada because it watches your connection so I used a program called Tunnel Bear for free, you get some free browsing space and if you post it on twitter you get even more space. I use it all the time now for browsing stuff we don't have in Canada.

Just download Tunnel Bear or a similar VPN switcher and then go to http://adobe.com and it should work becauase it won't be blocked.

If it still doesn't work then buy a cheap laptop for your other browsings needs because the point of blocking the connection is so the programs can't access the website so check it's registration information which eliminates the access to the website entirly.

Best of luck :)
 

benwiggy

macrumors 68020
Jun 15, 2012
2,382
201
Sounds like you mapped adobe.com to localhost in the hosts file.

The simplest and easiest way to edit a system text file is to use the free app TextWrangler.
You can browse all hidden files in its Open file dialog, and it will handle permissions and ownership on the fly, asking you for authorisation.
 

ShaggyMummy

macrumors newbie
Apr 17, 2014
1
0
What am I doing wrong?

Finished Repairing Disk Permissions, then Verified Disk Permissions, and Restarted. Still cannot unlock the hosts file.

EDIT:
Got it! I had to use:
Code:
sudo nano /private/etc/hosts
to edit the hosts file within Terminal, Control-O to save, then hit the Return key and I was golden and ready to go.

Thanks for trying to help, I hope someone else gets use out of this thread :)

Ive tried this and even after i did permissions repair in disk utility (and restarted), terminal wont let me save the hosts file

Also terminal wont let me use sudo. I am on a user account with admin permissions but i still get "sudo can't open /private/etc/sudoers: Permission denied
sudo: no valid sudoers source found, quitting"

After using the command
"Nano /private/etc/hosts" and opening the file in the terminal GNU. I pasted in my changes and tried useing control-O then enter. I get the error "[ error writing /private/etc/hosts: Permission denied ]

Can anyone help?
What am i doing wrong?
 
Last edited:

ask27985

macrumors newbie
Feb 26, 2018
2
0
you can't unlock hosts because you don't have read/write permissions not just to the file but also to the folder

by typing

sudo chown /private/etc

and then entering root password, you can then unlock the hosts file.

you might also need to take ownership of the file itself. to do so type in this:

sudo chown /private/etc/hosts
[doublepost=1519679212][/doublepost]where to type the line sudo chown /private/etc/ and sudo chown /private/etc/hosts ?
 

DeltaMac

macrumors G5
Jul 30, 2003
13,472
4,409
Delaware
Type that command in your terminal (Applications/Utilities/Terminal)

If the terminal is new to you - when you type in your password, nothing will appear as you type your password. Press enter when complete.
 

ask27985

macrumors newbie
Feb 26, 2018
2
0
i still can't do it. is there any youtube video i can watch to solve this problem
 

DeltaMac

macrumors G5
Jul 30, 2003
13,472
4,409
Delaware
i still can't do it. is there any youtube video i can watch to solve this problem
"Can't do" what?
Unlock the hosts file?
Run the command?
Find the Terminal?
Or, you can run the command, but nothing appears to happen?

I don't think anything WILL happen, and I am not sure that command will even help you unlock the hosts file.
MUCH easier to simply click on the hosts file, then get info on the file (press cmd-i), then unlock that info window. Change the permissions so it shows that Everyone can open. Then you should be able to edit that file with your favorite file editor.

But, its also easy to find a youtube video, so with a simple search for "edit hosts file in OS X", here's one result:
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.