Was instructed to write sudo command, returned with command not found

Discussion in 'macOS' started by xtreamest822, Feb 9, 2011.

  1. xtreamest822 macrumors newbie

    Joined:
    Feb 9, 2011
    #1
    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?
     
  2. Dalton63841 macrumors 65816

    Dalton63841

    Joined:
    Nov 27, 2010
    Location:
    SEMO, USA
    #2
    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.
     
  3. sammich macrumors 601

    sammich

    Joined:
    Sep 26, 2006
    Location:
    Sarcasmville.
    #3
    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
     
  4. richard.mac macrumors 603

    richard.mac

    Joined:
    Feb 2, 2007
    Location:
    51.50024, -0.12662
    #4
    yeah open wasnt used. you can also enter

    Code:
    sudo open /Applications/TextEdit.app /etc/hosts
    nano ftw! always forget how to use vi and emacs
     
  5. xtreamest822 thread starter macrumors newbie

    Joined:
    Feb 9, 2011
    #5
    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?
     
  6. xtreamest822, Feb 10, 2011
    Last edited: Feb 10, 2011

    xtreamest822 thread starter macrumors newbie

    Joined:
    Feb 9, 2011
    #6
    ...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?
     
  7. LPZ, Feb 10, 2011
    Last edited: Feb 10, 2011

    LPZ macrumors 65816

    Joined:
    Jul 11, 2006
    #7
    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.
     
  8. xtreamest822 thread starter macrumors newbie

    Joined:
    Feb 9, 2011
    #8
    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.
     
  9. LPZ, Feb 10, 2011
    Last edited: Feb 10, 2011

    LPZ macrumors 65816

    Joined:
    Jul 11, 2006
    #9
    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].
     
  10. xtreamest822 thread starter macrumors newbie

    Joined:
    Feb 9, 2011
    #10
    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.
     
  11. LPZ macrumors 65816

    Joined:
    Jul 11, 2006
    #11
    No output is fine for that command. Assume it flushed the Directory Service cache and proceed from there.
     

Share This Page