免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
shell腳本:通過shell實(shí)現(xiàn)linux用戶管理和監(jiān)控
shell腳本:通過shell實(shí)現(xiàn)linux用戶管理和監(jiān)控   

            
界面展示:

 
  1. 創(chuàng)建shell腳本文件:

  2. touch menu.sh

    touch index.sh

    touch welcome.sh

  3. 賦予腳本文件可執(zhí)行權(quán)限:

    chmod a+x menu.sh index.sh welcome.sh

  4. menu.sh

#!/bin/bash
#menu.sh
function menu(){
title="My Home"
name="Randy"
time=`date +%Y-%m-%d`
cat << qaz
#######################################################################
##              ***`echo -e "\e[32m $title \e[0m"`***                          ##
#######################################################################
## 1)Add a user                                                 ##
## 2)View all users                                             ##
## 3)Set passwd for user                                        ##
## 4)Delete a user                                              ##
## 5)Print disk space                                           ##
## 6)Print mem space                                            ##
## 7)Retrun menu      ##
## 8)Logout                                                     ##
## 9)Quit                                                       ##
#######################################################################
##   Name:$name Date:$time      ##
#######################################################################
qaz
}

4.index.sh

#!/bin/bash
#index.sh
function index() {
clear
. menu.sh
menu
while true
do
read -p "Please input a option:" option
case $option in
1)
read -p "Please input username:" name
useradd $name &>/dev/null
if [ $? -eq 0 ];then
echo "user ${name} is created successfully!!!"
else
echo "user ${name} is created failly!!!"
fi
;;
2)
str=`cat /etc/passwd | awk -F: '{print $1}'`
echo -e "\e[32m$str\e[0m"
;;
3)
read -p "input the username:" name
read -p "set password for the user:" pass
echo $pass | passwd --stdin $name &>/dev/null
if [ $? -eq 0 ];then
str="${name}'s password is set successfully"
echo -e "\033[30;47$str\033[0m"
else
str="${name}'s password is set failly!!!"
echo -e "\033[31;47m$str\033[0m"
fi
;;
4)
read -p "delete the user:" name
userdel -r $name &>/dev/null
if [ $? -eq 0 ];then
str="user ${name} is delete successfully!!!"
echo -e "\033[30;47m$str\033[0m"
else
str="user ${name} is delete failly!!!"
echo -e "\033[31;47m$str\033[0m"
fi
                ;;
5)
str=`df -Th`
                 echo -e "\033[30;47m$str\033[0m"
;;
                6)
str=`free -m`
echo -e "\033[30;47m$str\033[0m"
                ;;
7)
clear
menu
                ;;
8)
echo -e "\e[31mLogout ...\e[0m"
sleep 1
break
;;
                9)
                        echo -e "\e[31mQuit successfully!!!\e[0m"
                        exit
;;
*)
str="Input error please re-enter"
echo -e "\033[30;47m$str\033[0m"
;;
esac
done
}

5.welcome.sh

#!/bin/bash
#welcome
clear
echo -e "\e[31mWelcome\e[0m"
while true
do
read -p 'Please enter user name (Quit please input "q") :' name
if [ $name = "q" ]
then
break
else
read -p 'Please enter user password:' password
if [ $name = 'admin' ] && [ $password = 'admin' ]
then
str="Login successfully,Please Wait ......"
echo -e "\e[31m$str\e[0m"
sleep 2
. index.sh
index
else
str="Login failly"
 echo -e "\e[31m$str\e[0m"

fi
fi
done
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
運(yùn)行shell腳本時(shí)報(bào)錯(cuò)[[not found解決方法
Shell 的賦值命令
使用Shell腳本查找程序?qū)?yīng)的進(jìn)程ID,并殺死進(jìn)程
系統(tǒng)管理中 bash shell 腳本常用方法總結(jié)
Linux Shell編程參考大全
shell腳本編程
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服