Can't su anymore

LuKreme kremels at kreme.com
Wed Feb 27 22:19:50 PST 2008


On 25-Feb-2008, at 22:23, Dan Shoop wrote:
> On Feb 25, 2008, at 6:51 PM, LuKreme wrote:
>> On 25-Feb-2008, at 14:08, Don Montalvo wrote:
>>> "Jared Earle" <jearle at gmail.com> wrote:
>>>> On Mon, Feb 25, 2008 at 5:47 PM, Philip Mötteli
>>>> <Philip.Moetteli at tele2.ch> wrote:
>>>>> So, being in the root console, I can 'su' to root – though the  
>>>>> prompt
>>>>> changes.
>>>>
>>>> Does "sudo su -" work?
>>> I use "sudo -s"
>> But that is not the same thing as sudo su -
> Not always, but normally so, yes.


No, it is never the same thing.  One causes sudo to invoke a shell as  
root.  The other cause sudo to invoke su, which invokes a shell as root.

They are similar, they do somewhat the same thing (but not exactly),  
they are not, however, the same thing:

  [cerebus] ~ $ whoami
kreme
  [cerebus] ~ $ sudo -s
  [cerebus] ~ $ whoami
root
  [cerebus] ~ $ exit
  [cerebus] ~ $ sudo su -
cerebus:~ root# whoami
root

Notice the difference in the prompts?  sudo su - invokes a whole new  
shell without your environment.

from man su:
      -l      Simulate a full login.  The environment is discarded  
except for
              HOME, SHELL, PATH, TERM, and USER.  HOME and SHELL are  
modified
              as above.  USER is set to the target login.  PATH is set  
to
              ``/bin:/usr/bin''.  TERM is imported from your current  
environ-
              ment.  The invoked shell is the target login's, and su  
will
              change directory to the target login's home directory.   
This
              option is identical to just passing "-", as in "su -".

man sudo:
        -s  The -s (shell) option runs the shell specified by the  
SHELL envi-
            ronment variable if it is set or the shell as specified in
            passwd(5).

So, sudo -s keeps all your existing settings (and aliases), while `su - 
` does not.

--  
You think you can catch Keyser Soze? You think a guy like that comes  
this close to getting caught, and sticks his head out? If he comes up  
for anything it'll be to get rid of me. After that… my guess is you'll  
never hear from him again.



More information about the MacOSX-admin mailing list