Score:0

Why root password exist if I can be root with sudo -s or sudo -i, it need only sudo password so?

cn flag
pjk

sudo -i makes me root with sudo password

sudo -s, sudo su the same

su and su root need root password so it doesn't make sense to me, I can be root with only sudo password so why root password exist?

muru avatar
us flag
By default there is no root password. Password access for the root user is disabled. Why did *you* set a root password?
pjk avatar
cn flag
pjk
So why it is possible to set root password?
paladin avatar
kr flag
A root password exists to be able to login as root. Usually the user root is handled with special care, often makes root the only user which is able to login into a system when a critical system error occurred. For example, when your `/home` directory is mounted on a different drive and this drive has a malfunction and Linux cannot mount it - this making every user unable to login, but the root user may still be able to login, cause his home directory is `/root`.
muru avatar
us flag
@paladin the root user is a user, why shouldn't it be possible to set a password for them? It's perfectly possible to have a system without `sudo`, after all.
paladin avatar
kr flag
Also, when you want to change the home directory of a user, that user shouldn't be logged in. For example, user john wants to change his home directory, usually only a superuser may change a home directory. Doing sudo as user john won't help, because user john probably can't change his own home directory while logged in. So you would logout and login as root and change home directory of user john.
pjk avatar
cn flag
pjk
@paladin for example I have two users on my linux, peter and john. peter is in sudo and he is the owner of pc, john is also in sudo but peter don't want john to be able to use root account, so only peter knows root password but john still can be root because he is in sudo so he can just use sudo -i and that's it?
paladin avatar
kr flag
@pjk Whoever has sudo rights is also able to login into root account without password.
pjk avatar
cn flag
pjk
okay now I understand
Score:2
cn flag

The answer to your question is quite simple. On Ubuntu, the root password does not exist. The root account is not enabled. Thus, the root user cannot login on a standard Ubuntu system.

Instead there is the sudo system where selected "normal" users can assume administrator priviledges. So if you want a terminal with root privileges, su will not work, because root is not active. However, you still can obtain such prompt with sudo -i, where you act as a privileged normal user, thus provide your own user password.

See here for a more elaborate discussion of sudo versus logging in to the root account. You will learn you can activate the root account. If you then ask "Why root password exist if I can be root with sudo -s or sudo -i, it need only sudo password so?", well, in this case it is you who created the contradictory situation. By default, that situation is not there.

pjk avatar
cn flag
pjk
Okay now I'm really close to understand it but I have one more question from my comment above, let me copy it: for example I have two users on my linux, peter and john. peter is in sudo and he is the owner of pc, john is also in sudo but peter don't want john to be able to use root account, so only peter knows root password but john still can be root because he is in sudo so he can just use sudo -i and that's it? In this situation john should't be in sudo group to avoid it?
paladin avatar
kr flag
`sudo su` will work, or just `sudo passwd` will enable any sudo-user to set a root-password.
vanadium avatar
cn flag
@pjk being administrator is a job of trust. If there are two root users that do not trust each other, then that has to be solved at the management level, not at the level of the operating system ;) So indeed, one can be taken away root privileges if need be (and if that person did not yet destroy the system yet).
vanadium avatar
cn flag
@paladin yes, root can do everything, including activating the root account. Being administrator is a job of trust.
Artur Meinild avatar
vn flag
Being able to have root access _without_ a password still have its advantages - for instance you can still login as root with SSH keys even if the password is not set. This is far more secure than using a password.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.