Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
add comment

5 Answers 5

up vote 10 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
1  
@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
2  
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
show 3 more comments

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
add comment

Try this:

sudo passwd

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

share|improve this answer
add comment

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
add comment

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
add comment

Your Answer

 
discard

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.