4

I was under the impression that both the sudo password and the password that I use to login to Ubuntu are the same. But it happened that after logging into the system, tying the password in terminal followed by su, it raises Authentication failure ! error. Aren't they the same ?

Varun
  • 525

4 Answers4

11

sudo, by default, asks for your password, which is the password you use to login. On the other hand su ask for the password of the target user which, unless specified, defaults to root. Note that by default Ubuntu has an invalid password field set for root, effectively making it impossible to login as root.

4

I was under the impression that both the sudo password and the password that I use to login to Ubuntu are the same.

They are.

If you want a root prompt you need to type

sudo -i

when using the admin account. Mind though: there are not a lot of situations where you should need to use a root prompt and it is more likely you want to do something not the Ubuntu way.

Example (in order: "su", wrong password using "sudo su", correct password):

:~$ su
Password: 
su: Authentication failure
:~$ sudo -i
[sudo] password for xxxxx:
Sorry, try again.    
[sudo] password for xxxxx: 
:/home/xxxxx# 
  • Ubuntu does not have a "root" account (or better: it has been disabled). So "su" does not work since that is tied to the "root" account. "sudo -i" is tied to your admin user and will work.
Rinzwind
  • 309,379
3

If you use sudo (usually some command following it) it will ask you your login password, and you will gain root privilege.

when you use su you will be asked root user password (this is not the same as your login password unless you want it to be which is not recommended)

Usually, root user password is not set by default in Ubuntu on fresh install (in fedora you are asked to set root user password during installation). You have to set, only if you want to, root user password after installation.

Here is how you do it:

sudo -i

enter your login password and you will get something like this:

root@computer:/home/edward# 

now type:

passwd

now you will be asked to set root user password.

So they are different thing.

Alex Jones
  • 8,192
-1

Your username password and sudo password initially the same unless you change them.You can change the root user password using this command from the terminal

sudo password [username] (for example , root)
sudo -i
sudo passwd root

You should be able to login to root using sudo su from the terminal and then use your password. Hope that works for you.

TellMeWhy
  • 17,964
  • 41
  • 100
  • 142
bhordupur
  • 650