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.
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:
- there is no "default program". to run the shell defined for for the specified user, pass the
-i
option to the program. - 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 programvisudo
).
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).
You need to create a password for the root user
sudo passwd root
After that, you can log in as root
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