The passwd command on Linux enters the password for a given user account. If the user account is not provided as a parameter, passwd changes the password of the account currently used. For security reasons, it is not possible to pass the password on the command line.
The available option is:
Only root can change the password of other users. An ordinary user can run passwd to change their own password.
To change the Uira user’s password:
# passwd uira Enter new password for 'uira':
To view a user’s password status:
# passwd -S jira
jira PS 2019-04-11 0 99999 7 -1 (Password set, SHA512 crypt.)
To block a user account:
# passwd -l uira
Locking password for user uira.
passwd: Success
Notice that the status of the blocked account is changed to “LK”:
# password -W jira
jira OK 2019-04-11 0 99999 7 -1 (Password locked.)
Thus, the password in the /etc/shadow file got two asterisks “!!”
:
# cat /etc/shadow |grep uira
uira:!! $6$mqpxvbfi$zikapiccjtbcvlrphut.zesmqvvlhszjmhtjwofhov.6esz3w8g.iw7fogumnb9240knkk8.5kpcqkqn/wsgm/: 17998:0:99999:7::
To unlock a password:
# passwd -u uira
Unlocking password for user uira.
passwd: Success
Now the status is back to “PS”:
# passwd -S jira
jira PS 2019-04-11 0 99999 7 -1 (Password set, SHA512 crypt.)
To set a password to expire in 30 days:
# passwd -x 30 hours
Adjusting aging data for user uira.
passwd: Success
Notice that the password has expired to 30 days:
# passwd -S jira
jira PS 2019-04-11 0 30 7 -1 (Password set, SHA512 crypt.)
Learn much more about Linux in our online course. You can register here. If you already have an account, or want to create one, just log in or create your user here.
Share
The sudo command on Linux executes a given command as if it were another user.…
The ss command on Linux is extremely useful for investigating sockets, providing various information about…
Free Linux command shows the amount of total memory in use and available, as well…
The shell has structures for testing conditions and executing certain program sequences several times (loop),…
The /etc/fstab file stores the configuration of which devices should be mounted and what is…
The Netcat Command in Linux or nc is a utility used to do “almost anything”…
This website uses cookies.