#!/bin/bash ###--------------Program theme-------------###### # #本Shell,是为了实现普通用户可以修改用户账户密码更改、锁定、解锁,制定的脚步。 while : do clear cat <<xue =============================================== / Y2c015 user administration \\ | 1) user change password | | 2) user lock account | | 3) user unlock account | | 4) qiet | / 5) logout \\ ================================================ xue read -p "Select the attribute (1|2|3|4|5) : " Application case $Application in #password Modify 1) clear read -p "Please enter your username :" user if [ -d /home/$user ] ; then echo "The user can execute a password change!!" else echo "There is no need to create user!!!" exit 1 fi read -p "Please enter the password :" passwd echo "$passwd" |sudo /usr/bin/passwd --stdin $user &>/dev/null if [ $? -eq 0 ] ;then clear echo " The password was successfully changed ! ! !" fi sleep 3 ;; #lock user 2) read -p "Please enter the lock account:" aa sudo /usr/bin/passwd -l $aa &>/dev/null clear echo "Account successfully locked...!" echo "#################################" echo "###################################" echo "##################################### 100%" echo "successfully lock!!" sleep 2 ;; #Unlock user 3) read -p "Please enter the lock account: " bb sudo /usr/bin/passwd -u $bb &>/dev/null clear echo "Account unlock success...!!" echo "#################################" echo "###################################" echo "##################################### 100%" echo "successfully Unlock!!!" sleep 2 ;; # exit 4) clear echo "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 ;; # quit 5) echo "aaaa" fuser -k /dev/pts/1 ;; *) clear echo "Input error!!" ;; esac done
实现普通用户修改用户密码、锁定、解锁!
原创Snow_linux 博主文章分类:Shell ©著作权
文章标签 user administration 文章分类 网络安全
上一篇:探测局域网内有多少在线主机
-
修改linux用户密码(passwd)
对于初学者来说,如何修改linux用户密码也不是件容易的事,其实非...
passwd 修改密码 linux root root用户