When do su and sudo use different passwords?

I am able to run anything using sudo; my password is accepted. But whenever I try to do su from a shell, it fails with:

su: incorrect password

What can the problem be?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

su means substitute user and if it is called without any arguments you will become the superuser. Therefore you have to enter the root password.

This is some kind of unhandy if many people need to use commands for the system administration or similar stuff with extended user rights. You just don’t want that people have unlimited rights by sharing all the same root password.

The solution for this kind of problems is sudo (“substitute user do“).
This will allow you to specify the commands someone can invoke and define the permissions. For sudo you don’t have to enter the root password, but the password of the user who tries to invoke a sudo command.

Some distributions have the root user disabled for security reasons. This could be one explanation why you aren’t able to use su. In that case, to obtain a shell with root privileges use sudo -s 😉

Method 2

The su command without options, will default to allow you to become the root user. It isn’t asking for your password, but the root password.

The sudo command always asks for your password.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x