What is the difference between su and sudo?

I enter the su command, enter the password, and I get an error.

And when sudo, everything is fine.

What could be wrong?

Distribution: ubuntu.

Author: aleksandr barakin, 2016-05-12

3 answers

The program su is used to execute the specified command/program (by default, the program that is defined as a shell (shell for the specified user) on behalf of the specified user (by default, root) and it asks for the password of the specified user.

About the program sudo you can say almost the same, with two exceptions:

  1. there is no "default program". to run the shell defined for for the specified user, pass the -i option to the program.
  2. by default, it is not the password of the specified user that is requested, but the password of the user running the program sudo. which user, which programs and on whose behalf can be run, is determined by the contents of the configuration file /etc/sudoers (edited using the program visudo).

So you don't have an" error". just the password that you enter after starting the program su, not fits the root account (most likely, the password is not set at all, and this is normal and correct).

 20
Author: aleksandr barakin, 2016-05-12 10:21:39

You need to create a password for the root user

sudo passwd root

After that, you can log in as root

 1
Author: Yaroslav, 2016-05-12 07:47:37

The difference is big. At least, in the environment. At a minimum, the home directories ~ will be different. If you still want to use the shell from root - sudo su - to help.

And in general-read for a start three topics:

man man

man su

man sudo

 1
Author: Евгений Борисов, 2016-05-12 12:02:25