#! /Bin/bash ### -------------- Program Theme ------------- ####### this shell aims to enable normal users to change, lock, and unlock user account passwords, step by step. While: doclearcat <Xue ====================================== =============/y2c015user administration \ | 1) user Change Password | 2) User lock account | 3) User unlock account | 4) qiet |/5) logout ====================================================== =========== xueread-P "select the attribute (1 | 2 | 3 | 4 | 5): "applicationcase $ application in # password modify1) clearread-P" Please enter your Username: "userif [-D/home/$ US Er]; then Echo "the user can execute a password change !! "Elseecho" there is no need to create user !!! "Exit 1 firead-P" Please enter the password: "passwdecho" $ passwd "| sudo/usr/bin/passwd -- stdin $ user &>/dev/nullif [$? -EQ 0]; thenclear echo "the password was successfully changed!!! "Fisleep 3; # Lock user2) read-P" Please enter the lock account: "aasudo/usr/bin/passwd-L $ AA &>/dev/nullclearecho" account successfully locked ...! "Echo" ################################# "Echo "# ################################## "Echo "### ################################### 100% "Echo" successfully lock !! "Sleep 2; # unlock user3) read-P" Please enter the lock account: "bbsudo/usr/bin/passwd-U $ BB &>/dev/nullclear echo" account unlock success ...!! "Echo" ################################# "Echo "# ################################## "Echo "### ################################## 100% "Echo" successfully unlock !!! "Sleep 2; # exit4) clearecho" Good bye, welcome to use "echo-n" ["for I in {1 .. 3 }; do echo-n "###################" [$ I-EQ 3] & Echo-n "] "& Echo & Exit 0 sleep 1 done ;; # quit5) echo "aaaa" Fuser-k/dev/pts/1; *) clearecho "input error !! "; Esacdone
This article is from "A-snow _ Welcome !" Blog, declined to reprint!
Allows common users to modify, lock, and unlock user passwords!