Mac OS X gain root/superuser access using sudo

Contributor Icon Contributed by macster  
Tag Icon Tagged: Mac system administration  

The command line utility sudo is a wonderful way to provide fine-grained access control to different applications to different users. In this recipe, sudo will be used to easily gain full root/superuser access to a Mac running OS X.


Under Mac OS X, the root or superuser account is not enabled following installation. While it is possible to enable the root account, it is safer and potentially easier to use the sudo command to gain root access to the system.

From a terminal window, type

sudo -s

This will prompt you for a password which is the user’s password, not the root password (which will not be set). The first time you run sudo, it will print a conscience-oriented message before prompting for the password. Subsequent uses of sudo for that user will not print out that text. The -s option launches a shell as the target user (root). When successfully executed, the shell’s prompt should end with root#.

When done with root privileges, it is a good idea to demote yourself and return to your original user shell by typing:

exit

 

11 Comments -


  1. Adrian said on February 13, 2009

    This doesn’t work for me

    >sudo -s
    sudo: must be setuid root

    However, I see that /usr/bin/sudo is owned by another user. Is this the problem?

  2. Carl said on February 13, 2009

    I don’t think this is working for me,

    my shell’s prompt ends with back-3.2#

    am I in root access?

  3. Carl said on February 13, 2009

    sorry, i meant bash-3.2#

  4. Quinn McHenry said on February 13, 2009

    Yeah, a prompt ending with a hash # symbol usually denotes root’s shell prompt.

  5. Anonymous said on September 11, 2009

    In order to uninstall, install a particular new program and then reinstall an old program, I need to delete my /sw directory. But, I cannot even figure out how to find a terminal window so that I can use sudo.

    Can anyone tell me how to open up a terminal window so that I can use sudo?

  6. Gianpaolo said on October 1, 2009

    Hi,

    I`m trying to copy an Info.plist file into a Volume (The Sims3 Volume) for cracking porpouse. I`ve done everythingo but everytime I get that I can`t because the Sims3 Volume is read-only. I`ve tried to chmod the Volume but i get the same results. It says I can´t because it´s read-only.

    I´m doing all this using a root account

    Any help would be appreciated

  7. Anonymous said on November 6, 2009

    Response to peterenns:

    Go to Applications->Utilities to find your terminal application.

  8. Anonymous said on May 11, 2010

    Thank you, macster. This is exactly what I was trying to figure out.

  9. Matt said on January 18, 2011

    i thienk thats the problum idk

  10. Soppopp said on February 8, 2011

    i put in sudo -s then it says i am not in the sudoers file and it will be reported

  11. Adm3 said on April 1, 2011

    this might sound stupid, but you could right-click and select properties. If you are root, you should be able to give yourself full-access.

 

RSS feed for comments on this post. TrackBack URL

Leave a comment -