Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I understand what su - does

  • logs you into root with the root environment
  • (as opposed to su which logs you into root with your environment)

And I understand what sudo does

  • you are root for one command

But I am unsure what this does: sudo su -

Anyone care to clarify

share|improve this question

migrated from stackoverflow.com Feb 5 '10 at 22:18

This question came from our site for professional and enthusiast programmers.

1  
StackOverflow is for asking programming related questions. The site you're looking for (at least for this question) is SuperUser.com –  Terry Donaghe Feb 5 '10 at 22:18

3 Answers 3

up vote 32 down vote accepted

In addition to what you said, su requires the root password and sudo requires your user password

Therefore sudo su - will put you into a root environment but it will ask you for your user password instead of the root password (once sudo has given you root privileges, su - can be executed with no password).

share|improve this answer
    
+1 good explanation. If I config my sudo can I make it not require a password? That would made su require 'no password'? –  sixtyfootersdude Feb 8 '10 at 14:46
    
clear explanation –  Thiyagu ATR Jul 9 at 8:10
    
note that sudo -i is a somewhat more direct way of doing the same thing –  Sam Mason Jul 12 at 11:42

If you are allowed (configuration of sudo) to use the su command, it asks you for your password and then logs you in as root.

share|improve this answer

Short answer: you will get a root shell.

Long answer: it is different from doing 'su -' within a root shell. Once you exit (eg., Ctrl-D) from 'sudo su -', the execution of sudo will end.

Observed on Debian Wheezy with htop:

'sudo su -' has a child of 'su -', and 'su -' has a child of '-su'.

As mentioned above, root user can do 'su -' without entering password, so doing 'su -' inside of a root shell, you will have two different root shell processes. ending the inner one will let you return back to the outer one.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.