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

xtreamest822

macrumors newbie
Original poster
Feb 9, 2011
5
0
i was instructed to type "sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit /etc/hosts"

then i recieve a "command not found" response. i dont know much about terminal but this is really frustrating me. how do i get the command to execute?
 
instead of opening it in Textedit why not edit it from console. Much quicker imo.

Code:
sudo vi /etc/hosts
or
Code:
sudo nano /etc/hosts

Oddly I just tried your original command and it worked without a hitch on my system. Try the CLI editor and see what happens.
 
instead of opening it in Textedit why not edit it from console. Much quicker imo.

Code:
sudo vi /etc/hosts
or
Code:
sudo nano /etc/hosts

I wouldn't expect the average user to be able to use command line text editors.

You can use the following simpler command to achieve the same thing:

Code:
sudo open -a TextEdit /etc/hosts
 
thank you so much that easier command got me to the next step. but now i have a new snag. once i get to the host i cannot save any changes i make. i dont have "permission." how do i change this so i can edit host?
 
...and after i put in that code sudo open /Applications/TextEdit.app /etc/hosts, it tells me that text edit does not exist??

nvm i got textedit back in my apps. but now how do i get permission to edit Textedit?
 
Last edited:
...and after i put in that code sudo open /Applications/TextEdit.app /etc/hosts, it tells me that text edit does not exist??

nvm i got textedit back in my apps. but now how do i get permission to edit Textedit?

First, you are not editing TextEdit. What you are trying to edit is a file named hosts in the etc directory at the root of your file system. The hosts file is owned by root, and only root has permission to write to that file. The sudo command is being used to run the open command as root, but that's not what you want to do.

There are many ways to do what you want to do. I'd avoid TextEdit completely, and do the following:

1) Open Terminal (in Utilities).

2) In Terminal, enter

Code:
sudo pico /etc/hosts

Supply your password when asked to do so.

3) Type in the code you want to add to the hosts file. You can navigate through the text using the four arrow keys on your keyboard.

4) Press control-o (that's control and the letter o key) AND THEN THE RETURN KEY to save your changes.

5) Press control-x to exit from pico.

6) Quit Terminal; you're done.
 
Last edited:
ok so i entered my code in pico and when i hit control-o the bottom of the screen has white text with black background and says -File Name to Write: /etc/hosts

what do i do next? i click save and it tells me where i want to save it. and when i hit control-x it just makes a dud sound. arghhh...this is hard. HELP. sorry guys i guess im definitely a noob haha.
 
ok so i entered my code in pico and when i hit control-o the bottom of the screen has white text with black background and says -File Name to Write: /etc/hosts

what do i do next? i click save and it tells me where i want to save it. and when i hit control-x it just makes a dud sound. arghhh...this is hard. HELP. sorry guys i guess im definitely a noob haha.

Sorry, I wasn't completely clear. What you do next is just press return in response to File Name to Write: /etc/hosts

Then press control-x to quit pico.

[I've edited step 4 in my previous post to be more complete].
 
Last edited:
ok perfect! code was written successfully! woohoo!

now my next instructions are to open terminal and enter this:sudo dscacheutil -flushcache

but when i hit enter it doesnt do anything...more help please! we're almost there! thanks so much.
 
ok perfect! code was written successfully! woohoo!

now my next instructions are to open terminal and enter this:sudo dscacheutil -flushcache

but when i hit enter it doesnt do anything...more help please! we're almost there! thanks so much.

No output is fine for that command. Assume it flushed the Directory Service cache and proceed from there.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.