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'.

> 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.

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.

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 :-)

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.

More Like This

Retrieving data ...

This site contains user submitted content, comments and opinions and is for informational purposes only.
Apple may provide or recommend responses as a possible solution based on the information provided; every potential issue may involve several factors not detailed in the conversations captured in an electronic forum and Apple can therefore provide no guarantee as to the efficacy of any proposed solutions on the community forums.
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.