Sudo su vs su linux
Solution 1:
That's because su
asks for password of the user you're changing into (which by default is root) while sudo
asks for your own user account's password and checks if you are allowed to run the command.
When you run sudo su
you are asking sudo
to run the command su
as root, which gives you the root shell. If you are using only su
you will have to know the target user's password to have access.
Using sudo
without parameters implies that you want to use root. If you want to execute the command as another user, try sudo -u <username> <command>
Solution 2:
su
stands for switch (or substitute) user. With no user name given, it defaults to switching to root. It prompts for the password of the user you're switching to.
sudo
is used to run a command as root (i.e., with root permissions), or as other users. It prompts for your password, and checks that you're allowed to use sudo.
When you type su
, you're asking to switch to root, and the password that's requested is the root password. When you type sudo su
, you're asking to execute the command to switch to root as root, so the password that's asked for is yours.
Solution 3:
...and to fix the problem of not being able to use 'su' alone, sudo to a root shell, and set a password for root, with 'chpass'.