Previous 1 2 Next 17 Replies Latest reply: Dec 13, 2012 10:51 AM by kitehi
kitehi Level 1 Level 1 (0 points)

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)

    What do you mean by:

     

     

     

    i activated the root-user in system preferences

  • kitehi Level 1 Level 1 (0 points)

    alkhater wrote:

     

    What do you mean by:

     

     

     

    i activated the root-user in system preferences

     

     

    http://support.apple.com/kb/PH11331?viewlocale=en_US

  • BobHarris Level 6 Level 6 (14,930 points)

    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 (61,900 points)

    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?

  • BobHarris Level 6 Level 6 (14,930 points)

    > 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 (61,900 points)

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

  • Neville Hillyer Level 4 Level 4 (1,855 points)

    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 (25,715 points)

    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 (14,930 points)

    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 (25,715 points)

    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 (14,930 points)

    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 (25,715 points)

    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

  • kitehi Level 1 Level 1 (0 points)

    to give an example: sudo mdutil -a -i on

    What password?

     

    None of the passwords (user/ admin/root)  would be accepted.

  • Frank Caggiano Level 7 Level 7 (25,715 points)

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

Previous 1 2 Next