'sudo su' on Mountain Lion Terminal.app

Discussion in 'OS X Mountain Lion (10.8)' started by Kann, Jan 23, 2013.

  1. Kann macrumors newbie

    Joined:
    Apr 7, 2009
    #1
    I'm currently on Macbook Air with OS X 10.8.2 today. Regarding to this article from Apple, my root account is currently disabled.

    So, from a friend's suggestion, I just tried...

    Code:
    sudo su
    on my terminal. I know it's weird. The command seems unnecessarily redundant, but it grants me access to root right away. :eek::eek::eek:

    Is this normal? Could you guys please try running this command on your shell for me?

    ----------

    Also, it didn't even ask for my admin password. :eek::confused::confused:
     
  2. ChristianJapan macrumors 601

    ChristianJapan

    Joined:
    May 10, 2010
    Location:
    日本
    #2
    Did you at least got asked for a password ?

    Ok, just see you remark. Do you have password set to login to you machine/ auto login ? Did you entered the admin password short before with another command ?
     
  3. costabunny macrumors 68020

    costabunny

    Joined:
    May 15, 2008
    Location:
    Weymouth, UK
    #3
    The root account isnt exactly disabled by default - its not allowed to login. Means you can escalate to root in the shell, but not login to the mac either locally or remotely as the root user directly.

    When running 'sudo su' you are saying please let me switch user to superuser (root).

    It should however ask for your user password. That is the one you use to login to your mac with.
     
  4. Kann thread starter macrumors newbie

    Joined:
    Apr 7, 2009
    #4
    I just sudo with other commands while a go. May be this is the reason why it didn't ask for my password.

    ----------

    Aha, this explains it. Thanks for this info! :D:D:D
     
  5. ChristianJapan macrumors 601

    ChristianJapan

    Joined:
    May 10, 2010
    Location:
    日本
    #5
  6. Macman45, Jan 23, 2013
    Last edited: Jan 23, 2013

    Macman45 macrumors demi-god

    Macman45

    Joined:
    Jul 29, 2011
    Location:
    Somewhere Back In The Long Ago
    #6

    Once you've used your password after the sudo command, that session will remain active and you can type commands without the password prompt. Useful for playing around with power settings etc...which I've been doing all morning....FInally cured the wake from sleep issue on my newbie..:)
     
  7. Armyguy6902 macrumors newbie

    Joined:
    Mar 11, 2013
    #7
    sudo su help

    ok so long story short. i just received my new 21.5 imac and had saved some info last week on my iPad regarding how to erase all stuff on my macbook air so i could then sell it. i was only able to get the first line to work in terminal. that line was
    sudo su

    then it asks for my password (i type it) and now on to the next line of text.

    dscl . -delete /groups/admin groupmembership first last (those are my names for my account)

    it gave me some error message. now im just going to restart and reinstall the OS from disk utility. as soon as my MBA starts up i am holding the command & S button and all of a sudden i am getting lines of txt like im using the MS-DOS prompt. needless to say i cant figure out how to reverse whatever it is that i did. any help would be greatly appreciated.

    additional info: at the bottom of the startup txt it says

    if you wish to boot the system:
    exit
    :/ root#
     
  8. jasonvp macrumors 6502a

    jasonvp

    Joined:
    Jun 29, 2007
    Location:
    Northern VA
    #8
    FWIW, I never understood that one. A lot of the systems administrators I know do the same thing. Assuming you have all privs in the sudoers file, you can run any command with it. Like, say, a shell.

    Code:
    sudo /bin/sh
    ...for instance. It'll still ask for your password, but it avoids the su step and just executes the shell. Voila: you're root.

    jas
     
  9. cjmillsnun macrumors 68020

    Joined:
    Aug 28, 2009
    #9

    Code:
    sudo -s
    will give you a shell with root privileges
     
  10. jasonvp macrumors 6502a

    jasonvp

    Joined:
    Jun 29, 2007
    Location:
    Northern VA
    #10
    Even better!

    jas
     
  11. switon macrumors 6502a

    Joined:
    Sep 10, 2012
    #11
    RE: env...

    Hi,

    While the "env" utility is deprecated, it is still found in the current Mac OS X at /usr/bin/env. If you set this executable's owner to root, the group to wheel, and its mode to setuid, then you can promote a command to root privileges using the env command. For example, if you execute the following:
    Code:
    env id
    it will return the euid set to root and the egid set to wheel. Note that the uid and gid are not changed, just the euid and egid. (Be careful when doing this, as you may not want everyone to have access to root privileges. So if you want to use this privilege promotion scheme, then you might consider copying the env utility to a directory that only you have access to, and changing the ownership and mode for this copy. This way not everyone on your system will have access to the env utility that will promote privileges. By the way, this is always a problem for any executable that has setuid and setgid privileges, but it is particularly dangerous for the "env" command since this command will run other commands with promoted privileges.)

    If you have root privileges, then you can change the ownership and mode of "env" using the following commands.
    The owner and group are set to root and wheel via:
    Code:
    chown root:wheel env
    The mode is set to setuid via:
    Code:
    chmod ugo+s env
    Regards,
    Switon
     

Share This Page