
To set or reset a user password in Linux, use the command passwd
Here are some tips!
When logged in as your regular account, simply type passwd at the command prompt to change your own password:
scott@localhost:~$ passwd Changing password for scott (current) UNIX password: Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully
The root user can change or set passwords for another account. Or instead of using root, issue sudo to temporarily raise permission and issue the command. (You all do use sudo, right?
)
In examples below, username is ‘scott’.
# passwd scott
or
$ sudo passwd scott Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully
Other cool stuff you can do:
Tack ‘l’ will temporarily “lock” the account by changing the password to include a ‘!’ at the beginning.
$ sudo passwd -l scott passwd: password expiry information changed.
And likewise, tack u will unlock:
$ sudo passwd -u scott passwd: password expiry information changed.
To force a password change on next login, use tack e. This is what I always do when setting up a new user’s account. Give them their initial password, and they can then create a new one upon login.
$ sudo passwd -e scott passwd: password expiry information changed.
And lastly, tack capital S will give the current status of a password for a specified user. (Locked/unlocked, no password/password, date of last change, and expiration details.)
$ sudo passwd -S scott scott P 06/02/2011 0 99999 7 -1
Cool!