How do I set the root password so I can use su instead of sudo? [duplicate]

Solution 1:

Warning: Directly logging in as root is like playing with fire, because one little typo is enough to lose critical data or make your system unbootable. Note that desktop environments will also function incorrectly if you login to them as root.

See these questions for the reasons behind why sudo is preferred and why root-login is disabled by default:

  1. What are the benefits of sudo over su?
  2. Why is there no option to login as root?

You may have noticed that you can’t log in as root on Ubuntu, this is because root doesn’t actually have a password set.

Enter the following command:

sudo passwd

You will be prompted for your current user's password, followed by the password you want to set for root. The messages prompted should be similar to the following:

[sudo] password for <username>: <Type your user password and press return>
Type new UNIX password: <Type the root password you want>
Retype new UNIX password: <Retype the root password you chose in the previous prompt>

The following message will appear after that:

passwd: password updated successfully

If the above message showed up on your terminal, you can now enter as root from your current user entering the following command:

su

And you will be prompted for the root password you've set. That's it!

Solution 2:

If you still want to use su after reading the warnings in the question, there is no need to set a root password. Just do sudo su and you're on your way with your regular password.

Solution 3:

What I do to create the root on ubuntu: first I do this

sudo -i

then

passwd

as @Zignd mentioned the classical messages will appear:

Type new UNIX password: [Type the root password you want]
Retype new UNIX password: [Retype the root password you chosen before]
passwd: password updated successfully

then I can use the su as a normal root acount...