隨筆-204  評論-90  文章-8  trackbacks-0
          #/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;;
                      0exit;;
                      *) menu;;
                  esac
              done
          }

          menu
          posted on 2012-10-17 11:25 一凡 閱讀(274) 評論(0)  編輯  收藏 所屬分類: linux
          主站蜘蛛池模板: 洛浦县| 房山区| 西乡县| 金阳县| 天祝| 东海县| 五原县| 浏阳市| 富蕴县| 南雄市| 甘肃省| 宜兰县| 柳河县| 固始县| 屏山县| 万州区| 清流县| 绍兴市| 磴口县| 进贤县| 密山市| 信阳市| 榆树市| 泾源县| 旬阳县| 宁津县| 平定县| 海原县| 肇庆市| 襄垣县| 汶川县| 航空| 虎林市| 章丘市| 习水县| 东城区| 历史| 大安市| 临泉县| 屏山县| 砚山县|