Error when trying to sudo a command in Terminal

Discussion in 'macOS' started by GenadeMusic, Apr 22, 2010.

  1. GenadeMusic macrumors newbie

    Joined:
    Apr 22, 2010
    #1
    I'm a bit new at using terminal and sudo commands. But I have a step by step instruction. Only problem is I'm running into a problem when trying to log in with my password.

    I'm working on a PowerPC G5. It's running Mac OSX 10.5.8

    Here is the error message that appears when I try to log in.

    2010-04-22 21:02:15.007 TextEdit[161:c0b] *** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0x4403, name = 'com.apple.TextEdit.ServiceProvider'
    See /usr/include/servers/bootstrap_defs.h for the error codes.


    A new window opens displaying this message

    ##
    # 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
    fe80::1%lo0 localhost


    Any idea of what I need to do?
     
  2. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #2
    The sudo command doesn't seem to be the issue, though you don't show it. The error is related to the TextEdit application. You haven't given much information so not much to help you with. So give more info on what you're up to and what you're running.
     
  3. GenadeMusic thread starter macrumors newbie

    Joined:
    Apr 22, 2010
    #3
    Sorry. The command I'm running is

    sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit /etc/hosts

    I'm basically trying to edit in some commands for a program that I'm having trouble fully installing or at least get fully running.

    Any other info I can give?
     
  4. mac2x macrumors 65816

    Joined:
    Sep 19, 2009
    #4
    That doesn't look like a valid command to me. Are you trying to change to that directory? If so you shouldn't need sudo. Just cd.
     
  5. jtara macrumors 65816

    Joined:
    Mar 23, 2009
    #5
    Do this instead:
    Code:
    sudo open /Applications/TextEdit.app/Contents/MacOS/TextEdit /etc/hosts
    You need to use the open command to run a GUI application from the shell.

    Alternately, for the simple editing you want to do, try:

    Code:
    sudo nano /etc/hosts
    nano is a simple non-GUI text editor. If you know WordStar, you're good to go. ;)
     
  6. Hal Itosis macrumors 6502a

    Hal Itosis

    Joined:
    Feb 20, 2010
    #6
    Looks like you're trying to open a file with TextEdit.app (and using sudo to get root privileges). The "normal" way of doing the former is either:

    open -t /etc/hosts

    or

    open -a /Applications/TextEdit.app /etc/hosts

    However, i'm not sure if adding a sudo prefix with 'open' will accomplish what you're after.

    --

    Check out the freeware TextWrangler. It will handle all the authorization within the app itself (no need for Terminal). Seriously, TextWrangler is a 'must-have' for the kind of thing you're trying to do there.


    Having said that, the right approach is to use a standard editor like nano (or vi, emacs).
     
  7. jtara macrumors 65816

    Joined:
    Mar 23, 2009
    #7
    No, he needs to use sudo because a normal user account doesn't have write access to /etc/hosts.
     
  8. anteanterior macrumors newbie

    Joined:
    Nov 8, 2009
    #8
    Telling TextEdit to /etc/hosts is not a valid command.

    Open on the other hand, that is if I'm not wrong, just tells Finder to open/execute a file/exec. Doing that with root privileges makes no difference as far as I know.

    What are you actually trying to accomplish?
     
  9. mac2x macrumors 65816

    Joined:
    Sep 19, 2009
    #9
    You're right, of course. My bad! :eek: FWIW, you have to be in an admin account to use sudo anyway.

    I get the same error as the OP (I'm working from an admin account of course), but interestingly, TextEdit opens the host database file when I don't use sudo, but a blank text doc opens when I do use sudo. :confused:
     
  10. MacManiac76 macrumors 65816

    MacManiac76

    Joined:
    Apr 21, 2007
    Location:
    White Mntns, Arizona
    #10
    There was actually no error in the command that was originally used. The first message that comes up is an error in the TextEdit.app program as previously stated. The error doesn't seem to be affecting the ability for the OP to open the /etc/hosts file as it does load in TextEdit after the initial error. I know some Terminal stuff changed in Snow Leopard compared to Leopard so the OP may be experiencing different results.

    I guess the real question now is what do you want/need to change in the /etc/hosts file for the program you're having trouble with OP?
     
  11. J the Ninja macrumors 68000

    Joined:
    Jul 14, 2008
    #11
    Yes it is, he is calling an executable, and giving it an argument of what file to use. There is nothing at all wrong with the command. In fact, that is how you open TextEdit as root. "sudo open TextEdit" will only run the open command as root, it will not open the app as root.
     
  12. Hal Itosis macrumors 6502a

    Hal Itosis

    Joined:
    Feb 20, 2010
    #12
    True enough, it would seem. Still, it's a rather odd way of going about things (in order to edit the hosts file). Also strange is: the session which runs this command appears to hang... as it waits for that instance of TextEdit to finish. [no prompt gets returned until "TextEdit" quits.]

    Apparently, the error message in post #1 only happens if TextEdit was already running, in which case we will see two instances appear in the dock...
    Code:
    $ [COLOR="Blue"]ps axcu |sed '1p;/ Text/!d'[/COLOR]
    USER       PID  %CPU %MEM      VSZ    RSS   TT  STAT STARTED      TIME COMMAND
    root     41728   0.0  0.5   217900   6008 s000  S+   10:53AM   0:00.32 TextEdit
    halito   41241   0.0  0.5   219112   6932   ??  S    10:52AM   0:00.37 TextEdit
    
    But again, if someone isn't comfortable enough working on the command line to simply do sudo nano /etc/hosts, then i'd recommend using TextWrangler as a powerful GUI alternative.
     
  13. GenadeMusic thread starter macrumors newbie

    Joined:
    Apr 22, 2010
    #13
    Thanks for you help guys. I'm trying to input some commands that will let a couple of design programs run as updated versions. I don't think there are supported anymore and I was able to find text commands that will help run them completely.

    Jtara your command you gave me worked except I was unable to save. Is it because I am working in TextEdit?

    Sad thing is now Terminal won't even let me put in my password so I'm wondering if I frigged something up. I try typing but nothing appears.

    This starting happening after I tried sudo nano /etc/hosts to avoid using TextEdit.

    Not to ask for new help, but does anyone know what I did wrong to now not be able to enter in any password? I didn't save anything or make any changes when working in Terminal.

    For added info, I am on the administrator account. Although I did buy this computer used and did not reinstall the operating syatem (it has already been wipe clean and everything seemed to be ready to make this computer my own.
     
  14. Hal Itosis macrumors 6502a

    Hal Itosis

    Joined:
    Feb 20, 2010
    #14
    Sounds perfectly normal to me. (nothing —not even bullets —gets echoed. Just proceed).
     
  15. MacManiac76 macrumors 65816

    MacManiac76

    Joined:
    Apr 21, 2007
    Location:
    White Mntns, Arizona
    #15
    That is normal for the password input to not echo anything but I don't think that's what he means.

    When you load Terminal now does it just hang at a blank screen without the usual prompt ever appearing where you would input commands?
     
  16. GenadeMusic thread starter macrumors newbie

    Joined:
    Apr 22, 2010
    #16
    The password does work. I didn't realize it that it remained blank.

    There is no blank screen at any point. Two things happen to me.

    1. After entering the command sudo open /Applications/TextEdit.app/Contents/MacOS/TextEdit /etc/hosts it opens a textedit page where I but in my additions, but then I am unable to save. I get a message saying I need permission to do so, an to go to the file and click info set permissions, but this isn't just some textedit file on my HD, right?

    2. I enter sudo nano /etc/hosts and it opens a new terminal window where it gives me options, but I can't paste in my additions.

    I don't think I shouldn't be messing around too much more with Terminal, at my current level of experience. I'll take a look at TextWrangler see if that's more useful. Thanks everyone.
     

Share This Page