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 used the 'useradd' command to create a new account, but I did so without specifying the password. Now, when the user tries to log in, it asks him for a password. If I didn't set it up initially, how do I set the password now?

share|improve this question

3 Answers 3

up vote 7 down vote accepted

Easiest way to do this from the command line is to use the passwd command with root privileges.

passwd username

From man 1 passwd

NAME
       passwd - update user's authentication token
SYNOPSIS
       passwd  [-k]  [-l]  [-u [-f]] [-d] [-n mindays] [-x maxdays]
       [-w warndays] [-i inactivedays] [-S] [--stdin] [username]
DESCRIPTION
       The passwd utility is used to update user's authentication token(s).

After you set the user password, you can force the user to change it on next login using the chage command (also with root privileges) which expires the password.

chage -d 0 username

When the user successfully authenticates with the password you set, the user will automatically be prompted to change it. After a successful password change, the user will be disconnected, forcing re-authentication with the new password.

See man 1 chage for more information on password expiry.

share|improve this answer
    
Oh... ok! :) That's simple enough... I thought passwd only resets one's own account. –  Paul Jul 5 '12 at 18:25
1  
If you leave off a username, it defaults to your account. –  uther Jul 5 '12 at 18:27

It's fairly simple. From the command line issue either

sudo passwd USERNAME

and you'll be prompted to change the users password. You may also su to the user in question and then run 'passwd'

Useradd doesn't ask for password. adduser does.

share|improve this answer

After adding new user if you are loggedin as a 'root' then you can set the password using command

passwd <username>

Or, if you are not root, you can run

sudo passwd <username>

To set the password.

Or if you are root then you can 'su' to the user and run 'passwd' to set the password.

su <username>
passwd
share|improve this answer
    
Also if you can login as the user you want to change the password of, login as that user and type passwd. –  E Carter Young yesterday

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.