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

okizen

macrumors member
Original poster
Jan 21, 2012
92
0
In windows 7 they are in /windows/system32/drivers/etc/ but where are the host files in Mac Lion OS X located?
 
In windows 7 they are in /windows/system32/drivers/etc/ but where are the host files in Mac Lion OS X located?

Step 1 – Open the Terminal.app

Either by start typing Terminal on the Spotlight, or by going into Applications -> Utilities -> Terminal.

Step 2 – Open the hosts file

Open the hosts by typing on the Terminal that you have just opened:

Code:
$ sudo nano /private/etc/hosts

Type your user password when prompted.

Step 3 – Edit the hosts file


Step 4 – Save the hosts file

When done editing the hosts file, press control-o to save the file.
Press enter on the filename prompt, and control-x to exit the editor.
 
Step 1 – Open the Terminal.app

Either by start typing Terminal on the Spotlight, or by going into Applications -> Utilities -> Terminal.

Step 2 – Open the hosts file

Open the hosts by typing on the Terminal that you have just opened:

Code:
$ sudo nano /private/etc/hosts

Type your user password when prompted.

Step 3 – Edit the hosts file


Step 4 – Save the hosts file

When done editing the hosts file, press control-o to save the file.
Press enter on the filename prompt, and control-x to exit the editor.

Thanx SandboxGeneral. But it keeps asking me for a password even though I haven't setup one up and after 3 attempts it logs me off again. Is there a way around this?
 
Thanx SandboxGeneral. But it keeps asking me for a password even though I haven't setup one up and after 3 attempts it logs me off again. Is there a way around this?

You should have an admin password that you use to log into your Mac or install apps. You should have set it when you first set up your Mac.
 
You should have an admin password that you use to log into your Mac or install apps. You should have set it when you first set up your Mac.

Thanx GGJstudios. I've now set up my admin password and all is working (so far).
 
Hi

Sorry for jumping onto this post.

I have followed the instructione above, but the Terminal is not loading the Hosts file, I am not being asked for a password.
 
Without seeing the exact commands you typed and the exact response from the system, it's hard to know what is going on.

If you are unfamiliar with the Terminal environment, I would recommend using TextWrangler, a free text editor app, which can open hidden system files and handle the permissions easily.

TW will let you browse hidden files and folders in the Open file dialog, and then ask for authorisation if required. It will also save the file with changes made, leaving the the file with the correct attributes.

It's on the Mac App Store, and can also be downloaded from the Bare Bones website. I consider it (or its paid big brother, BBEdit) essential for any Mac user.
 
i can't open hosts file with text wrangler application.

i can see the hidden files, but fail to open it.
Thank you for help.
 
Is it required use a terminal-based editor such as nano, vim or emacs? Can you edit root:wheel-owned files with a GUI editor? If you attempt to save, does it ask you for the sudo password, or does it fail?
 
Is it required use a terminal-based editor such as nano, vim or emacs? Can you edit root:wheel-owned files with a GUI editor? If you attempt to save, does it ask you for the sudo password, or does it fail?
See my post above about using TextWrangler.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.