#/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
posted on 2012-10-17 11:25
一凡 阅读(259)
评论(0) 编辑 收藏 所属分类:
linux