#/bin/bash
del_user() {
echo "請輸入用戶名:"
read user
echo "請確認(rèn)是否刪除(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" 已創(chuàng)建 ------|"
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
一凡 閱讀(266)
評論(0) 編輯 收藏 所屬分類:
linux