The Linux Newbie Guide  ⇒    Fundamentals     Advanced     Supplement   Command Index   ENG⇒中
All rights reserved, please indicate the source when citing
  

passwd - Change Password




The passwd command is related to user account management. Regular users can use passwd to change their own passwords. If you want to change someone else's password, lock an account, set password expiration days, and perform advanced management tasks like those, you'll need superuser privileges.

The basic syntax of the passwd command is passwd [OPTIONS] [USERNAME].

Here are some commonly used options for the passwd command:

 

Example (Requires root login):
# Delete the password for user patrick (no password required for future logins)
# This action can only be performed by the root user
# The "-d" flag is used to delete the password
# The user "patrick" is specified after the command
# The user will still be able to log in without a password
# However, only the root user can perform such an action
# This example demonstrates root-level actions; use caution.
# passwd patrick -d
# Lock the account for user andy (they won't be able to log in)
# The "-l" flag is used to lock the account
# passwd -l andy 
# Change the password for user frank
# The user will be prompted to enter a new password
# passwd frank

For more explanations and examples of the passwd command, you can refer to the provided link.