Changing User Passwords from the Command Line

bash-3.00# passwd stfa
Changing password for “stfa”
stfa’s New password:
Enter the new password again:

Any time a password needs to be changed, whether by a regular user or the superuser, the passwd command is used. Normally an ordinary user on the system can change his or her own password (but nobody else’s). When invoked, the user is prompted to enter the existing password. Upon entering the correct password, the user is prompted to enter the new password. After the new password is entered, the user is prompted to enter it again. This is done for verification purposes and to ensure the user didn’t make a typing error. If the second password does not match the first, the password is not changed and the user is returned to the shell.

If a user forgets his or her password, the user must seek the assistance of the administrator. The administrator can change any other user’s password by invoking passwd with an argument of the user’s login name.

As mentioned previously, there is an option when creating an account to disallow user changes to his or her password. In this case only the administrator, as super-user, can change the user password.

If, for some reason the root password needs to be changed, the administrator should invoke passwd while logged in as superuser. When changing or assigning a password as a user, note the following:

  • Passwords must contain at least 6 characters. Though a password may be assigned more characters, only the first eight are significant.
  • Passwords must contain at least two alpha characters (upper or lower case) and at least one numeric or special character. This enforces a certain level of security within the password structure.
NOTE: When you use the passwd command, a copy of the old /etc/passwd file is saved in /etc/opasswd.

You can also use the passwd command to change password aging for an account.

passwd -f -n min -x max name

min and max are expressed in days but will be rounded up to the nearest week. The -f option forces a user to change his or her password at the next login.

Enforce password aging for the account font:

passwd -n 7 -x 35 font

Force the user buddy to change his password at the next login:
passwd -f buddy

Leave a Reply

Your email address will not be published. Required fields are marked *

CAPTCHA * Time limit is exhausted. Please reload the CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.