Why sudo requires user password and not root password?
Solution 1:
Any user that has been granted permissions by a system administrator can use the sudo
command to perform actions with root privileges. su
, on the other hand, can be accessed only by users knowing the password of the target account.
-
sudo
allows a privileged user to execute a command as another user. If no user is specified, then that other user will beroot
. The user needs to give his/her password. The security system then checks whether that user has permission to act as root. -
su
allows to temporarily become another user to execute commands. If no user is specified, then the user will beroot
. Thus, the password of the target user needs to be entered. On Ubuntu, asu
to becomeroot
will not work, because theroot
account is by default not enabled - you can't login to it. You can however open a root shell withsudo -i
, if you have the priviledges. This way, you run a shell with root privileges without being logged in to a root account.
The first user created on a freshly installed Ubuntu system, user 1000, automatically is allowed to use sudo
to gain root privileges. Any other user must explicitly be granted "sudo" permissions by a user that already has such permissions. Users without such permission will not be able to use sudo
to execute commands with root privileges.