linux下创建/删除用户

#/bin/bash

 

del_user() {

echo “请输入用户名:”

read user

echo “请确认是否删除(y/n)?”

read isDel

if [ $isDel = ‘y’ ]; then

userdel -r $user

echo -e “\t\t\t\t|——————————|”

echo -e “\t\t\t\t|——- 用户 ‘$user’ 已删除 ——|”

echo -e “\t\t\t\t|——————————|”

fi

}

 

add_user() {

echo “请输入用户名:”

read user

useradd $user -d /work/$user

passwd $user

echo -e “\t\t\t\t|——————————|”

echo -e “\t\t\t\t|——- 用户 “$user” 已创建 ——|”

echo -e “\t\t\t\t|——————————|”

}

 

menu() {

while :

do

echo “1.添加用户”

echo “2.删除用户”

echo “0.退出”

echo -e “\n请选择:”

read choice

case $choice in

1) add_user;;

2) del_user;;

0) exit;;

*) menu;;

esac

done

}

 

menu

评论

此博客中的热门博文

FreeBSD安装Pure-FTPd及user manager for PureFTPd

debian lighttpd php ssl

解决nginx出现File not found的问题