Passwd and Usermod Command
PAGE TAGS: linux change password, linux password, linux passwd, linux set password, linux usermod command, linux usermod, usermod
Password and User Account Security Linux Commands
passwd name = Assign or change the password for a user. You will be prompted to enter the password. Example: passwd badams changes the password for the badams account.
Use passwd without a user account to change the current user password.
passwd -d name = Remove the password from an account. Example: passwd -d badams removes the password from the badams account.
passwd -x # name = Set the number of days a password can be used (password expiration time). Example: passwd -x 40 badams requires badams to change his password every 40 days.
passwd -n # name = Set the minimum number of days a password exists before it can be changed. Example: passwd -n 10 badams means that badams cannot change his password for 10 days following the most recent change.
passwd -w # name = Set the number of days before the password expires that the user is warned. Example: passwd -w 2 badams means that badams will be warned 2 days before his password expires.
passwd -i # name = Set the number of days following the password expiration that the account will be disabled. Example: passwd -i 7 badams will disable the badams account after 7 days if the password is not changed.
usermod -L name
passwd -l name = Disable (lock) an account. These commands insert a ! before the password, effectively disabling the account. Example: passwd -l badams locks the badams account.
usermod -U name
passwd -u name = Enable (unlock) an account. Example: passwd -u badams unlocks the badams account.