Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I can sudo, but I don't have the root password so I can't su root. Using sudo, can I change the root password?

share|improve this question
up vote 12 down vote accepted

So you want to run something like sudo passwd root? I don't think that this works everywhere.

share|improve this answer
In such cases, you need just flag it for mod attention. They can transfer it to be a comment. – Tshepang Mar 17 '11 at 12:49
@Tshepang - @faif doesn't even have flagging permissions. Those require 15 rep. I've flagged the post for him. – Iszi Mar 17 '11 at 12:54
@Iszi: Oh, I actually thought everyone can flag. – Tshepang Mar 17 '11 at 12:55
@Tshepang - New users with just 1 rep can only create non-wiki posts and comment on their own posts. See unix.stackexchange.com/privileges for more details. – Iszi Mar 17 '11 at 12:59
I'm not aware of any systems which force root to provide the previous root password. (After all all, you could change it with sed and the /etc/shadow file.) But maybe I haven't used enough "serious systems". Can you give an example of one such system? – mattdm Mar 17 '11 at 14:06

You can also just use

sudo su

and keep the root account without password.

share|improve this answer
Once I understood I can do this, I did "passwd -d root". Thanks! – ripper234 Mar 17 '11 at 13:21
But why was my answer downgraded after having been accepted ? – philfr Mar 17 '11 at 15:52

Try this:

sudo passwd

Note that you also wanna log in using su - instead of su (more info).

share|improve this answer

you can also use sudo with the "-i" option. this will log you in as root without using the su command.

sudo -i

share|improve this answer

You can change all these options in sudoers file, even make no password if you want( I would not recommend this though).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.