Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am superadmin of a server and like to change password of an existing user . How can I do that ?

I tried

usermod -p 'new-password' john

but it didn't worked ?

share|improve this question

4 Answers 4

up vote 3 down vote accepted

You may use passwd:

sudo passwd USERNAME 

You need not sudo if you're superuser yourself

share|improve this answer
    
sudo require root password :) –  Achu May 13 '12 at 18:41
    
@Achu: it's required current user password. But he is superuser. –  RiaD May 13 '12 at 19:31
    
What does superuser represent? –  Achu May 13 '12 at 19:37

The reason it didn't work is because usermod's -p option expects the password to be encrypted already.

From usermod's man page:

 -p, --password PASSWORD
       The encrypted password, as returned by crypt(3).

To set a password in this way is not recommended.

Instead You should use passwd <username>. This should (as usermod) be done as root (if you're not changing the currently logged in users password).

To change the password for user foo.

sudo passwd foo

This will prompt for a new password.

Have a look at the man-page for passwd for more info on setting for example expire time.

Good Luck!

share|improve this answer

The usermod -p flag is expecting the data to be the password already in an encrypted format.

Use "openssl passwd" to generate the encrypted data, or do it like this:

usermod -p `openssl passwd` (USERNAME)
share|improve this answer

Just type

passwd

In this way normal user can change own password without root privilege if you don't have.

share|improve this answer

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.