7

Asking because of curiosity. :)

When I type

sudo su

It asks for my user password. And when I type just

su

It asks for the root user password. But both the commands directs me to the root terminal. Then why is there such a difference?

marked as duplicate by muru, Community May 8 '15 at 7:58

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    @muru The OP is asking difference between su and sudo su not sudo -s or sudo -s – Maythux May 8 '15 at 7:58
  • 2
    @NewUSer read again. – muru May 8 '15 at 7:59
  • 1
    There is never a good reason to run sudo su. I've always wondered why this is so commonly suggested in the Ubuntu world. It is clumsy, inelegant and adds needless overhead. Just run su if you've set up the root account or sudo -i if you haven't. sudo su is just silly. – terdon May 8 '15 at 8:43
  • 1
    @terdon Usually when the user is on a corporate LAN the system administrators may not share the root user password with all the employees. In such a scenario its easier for a user to become root by putting sudo su and inserting user password. Since majority of Linux users are workers under corporates, say IT, I guess this could be a reason. :) – Anonymous Platypus May 8 '15 at 9:16
  • 1
    @AnonymousPlatypus no, that's when you use sudo -i, or sudo -s, you might also want to use -E, depending on what you want to do. What you don't want is sudo su. Both because there's no reason to run two programs when one is enough and because that way you can control the resulting environment much better. – terdon May 8 '15 at 9:27
9

sudo su means run the command su as sudo which means as root. Here the system will ask you for your password since you are a sudoer. After you enter your password, you now have root privileges. So su command won't ask for a password. It's same as if you are a root then su to any other user will not ask for password because you are a root.

When you just run the command su, you are running it as a regular user. Since su means switch to user root, you will be asked for the root password.

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