Creating and Managing User Accounts
passwd
The passwd utility is used to change an existing user’s password. For example, earlier we created a new user named lmorgan with useradd. However, because we didn’t use the –p option in the command line, the lmorgan account doesn’t have a password and is locked.
You can see this using the –S option with passwd. For example, we could enter
passwd –S lmorgan
at the shell prompt, as shown here:
openSUSE:/ # passwd -S lmorgan
lmorgan LK 03/14/2014 0 99999 7 -1
Notice that LK is displayed in the output.
In short, this account is unusable. To enable this account, we need to add a password. We
can do this using passwd. The syntax is
passwd username.
In this case, you would enter
passwd lmorgan
(as root). When you do, you are prompted to enter a password for the specified user, as
shown here:
openSUSE:~ # passwd lmorgan
New password:
Retype new password:
passwd: password updated successfully
Enter the password you want to use at the prompts. After doing so, you can enter
passwd –S lmorgan
again to view the account status, as shown next:
ws1:/ # passwd -S lmorgan
lmorgan P 03/14/2014 0 99999 7 -1
Notice that the account status is set to P, indicating that the password has been set and is valid.
When working with passwd, you can also use the following options:
• –l
Locks the user’s account. This option invalidates the user’s password.
• –u
Unlocks a user’s account.
• –d
Removes a user’s password.
• –n
Sets the minimum number of days required before a password can be changed.
• –x
Sets the maximum number of days before a password must be changed.
• –w
Sets the number of days prior to password expiration when the user will be warned
of the pending expiration.
• –i
Sets the number of days to wait after a password has expired to disable the account
LX0-104 Exam Objectives (K)
No comments:
Post a Comment