Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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 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
the best answer is here:, note to checkout the comments as well – ryenus Jun 30 '15 at 4:03
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 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

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

Just type


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

share|improve this answer

The way to assign a password with usermod (which is what the OP actually asked for) is to use a crypt() hashed password for the -p argument.

HASH=$(perl -e "print crypt(${PLAINTEXT},${SALT})")
echo "Password Hash = \"${HASH}\""

Then use that in your usermod -p command line argument:

usermod -p ${HASH} john
share|improve this answer

A non-interactive single line command for changing the password of a user:

sudo usermod -p `perl -e "print crypt("new-password","Q4")"` john

usermod -p requires encrypted password to work. Please note the new-password will be visible for users who can list the processes.

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.