Skip navigation

Terminal root user

1437 Views 17 Replies Latest reply: Dec 13, 2012 10:51 AM by kitehi RSS
1 2 Previous Next
kitehi Calculating status...
Currently Being Moderated
Dec 9, 2012 4:41 PM

Hi,

 

i activated the root-user in system preferences but the given password wont work in terminal, when i type a su (sudo) command.

Even my administrator or user password wont work...

 

Who can help?

 

Thanks

kitehi

MacBook Pro, OS X Mountain Lion
  • alkhater Level 2 Level 2 (205 points)
    Currently Being Moderated
    Dec 9, 2012 2:36 AM (in response to kitehi)

    What do you mean by:

     

     

     

    i activated the root-user in system preferences

  • BobHarris Level 6 Level 6 (12,505 points)
    Currently Being Moderated
    Dec 9, 2012 4:56 AM (in response to kitehi)

    su wants the 'root' account password

     

    sudo wants the password of the account you are currently using, and that account must either be a Mac OS X admin account or have had an entry added to the sudoers file.

     

    When prompted for the password, you must enter it blindly followed by 'return'. The password will not be echoed, there will be no dots displayed, nothing will be displayed while you are entering your password. Just assume it is being entered, then enter 'return'.

  • baltwo Level 9 Level 9 (59,150 points)
    Currently Being Moderated
    Dec 9, 2012 4:40 PM (in response to BobHarris)

    su wants the 'root' account password

    IIRC, you can use:

     

    sudo su

     

    and supply the admin user password. AFAIK, this lets you emulate the root user or am I missing something?

    27" i7 iMac SL, Lion, OS X Mountain Lion (10.8.2), G4 450 MP w/Leopard, 9.2.2
  • BobHarris Level 6 Level 6 (12,505 points)
    Currently Being Moderated
    Dec 9, 2012 6:12 PM (in response to baltwo)

    > AFAIK, this lets you emulate the root user or am I missing something?

     

    'root' is as state of mind.  Or more accurately, if the User ID is 0, then you ARE root.

     

    sudo su

     

    Will give you a User ID of 0, so every thing you do until you exit the session, will be done as 'root'.

     

    sudo su -

     

    Will even give all the standard 'root' enviornment variables including the 'root's PATH. Essentially the current process' environment is trashed and 'root's shell initialization scripts are run before you are given control.

     

    sudo su

     

    Keeps your environment variables, but you are now running as 'root'. 

  • baltwo Level 9 Level 9 (59,150 points)
    Currently Being Moderated
    Dec 9, 2012 11:13 PM (in response to BobHarris)

    Thanks. That was my understanding, since I've never had any occasion to enable the root user account.

    27" i7 iMac SL, Lion, OS X Mountain Lion (10.8.2), G4 450 MP w/Leopard, 9.2.2
  • Neville Hillyer Level 4 Level 4 (1,845 points)
    Currently Being Moderated
    Dec 10, 2012 8:03 AM (in response to kitehi)

    I have the same password for root and my admin account - it is simple and I have never discovered any problems with this.

  • Frank Caggiano Level 7 Level 7 (22,795 points)
    Currently Being Moderated
    Dec 10, 2012 8:23 AM (in response to BobHarris)

    sudo bash (or the shell of your choice) will have the same effect with the added bonus of being in the shell you want rather sh.

  • BobHarris Level 6 Level 6 (12,505 points)
    Currently Being Moderated
    Dec 10, 2012 8:44 AM (in response to Frank Caggiano)

    sudo bash

     

    is the same as

     

    sudo su

     

    in that it inherits your current environment variables.

     

    sudo -i bash -l

     

    is more analogous to

     

    sudo su -

     

    Giving you a clean environment, running a bash shell initialization to setup your root environment and leaving you in the /var/root home directory.

     

    A lot depends on what you want to do when being root.

     

    in most situations 'sudo command' is good enough.

     

    If you want root prompt, then a lot depends on what you want to do.  If running a few ls, mv, rm, etc... commands, sudo su or sudo bash is fine.  If you are going to run some complex scripts, it may be important to have root login PATH and other environment variables that may not exist in your normal user account environment.

  • Frank Caggiano Level 7 Level 7 (22,795 points)
    Currently Being Moderated
    Dec 10, 2012 8:52 AM (in response to BobHarris)

    Screen Shot 2012-12-10 at 11.49.44.png

     

    and

     

    Screen Shot 2012-12-10 at 11.49.23.png

  • BobHarris Level 6 Level 6 (12,505 points)
    Currently Being Moderated
    Dec 10, 2012 9:01 AM (in response to Frank Caggiano)

    OK, I did not really mean to say they are the "Same", rather they are similar in that they both inherit your currnet environment vs the other 2 sudo examples where you get the 'root's environment based on running the root's shell initialization scripts.

     

    Again it all depends on what you want to do as root.

     

    I have had situations where inheriting my normal user environment caused problems.

     

    But most of the time it does not matter, so I just use 'sudo command'.

     

    NOTE: /bin/sh on Mac OS X is bash with a different name.  So most of what you would do with bash can be done with /bin/sh.  NOT 100% but enough that it doesn't matter that much.  Again depending on what you want to do :-)

  • Frank Caggiano Level 7 Level 7 (22,795 points)
    Currently Being Moderated
    Dec 10, 2012 9:10 AM (in response to BobHarris)

    Yes sh and bash on OS X are the same executable. I do beleive they will behave differently depending on argv0.

     

    Of course if you use bash then there is almost no difference but if you use one of the others like csh or ksh then there is a difference and being able to run root in the shell you are comfortable wiht tends to limit stupid mistakes.

     

    But as you say there is almost no need to actually run as root, sudo will do 99.9% of the things you need to do.

     

    regards

  • Frank Caggiano Level 7 Level 7 (22,795 points)
    Currently Being Moderated
    Dec 10, 2012 10:47 AM (in response to kitehi)

    If you are in an admin account then you use the password you used to log into the system.

1 2 Previous Next

Actions

More Like This

  • Retrieving data ...

Bookmarked By (2)

Legend

  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.