shell linux管理,shell脚本:通过shell实现linux用户管理和监控

《shell脚本:通过shell实现linux用户管理和监控》由会员分享,可在线阅读,更多相关《shell脚本:通过shell实现linux用户管理和监控(7页珍藏版)》请在人人文库网上搜索。

1、shell 脚本:通过 shell 实现 linux 用户管理和监控 shell 脚本:通过 shell 实现 linux 用户管理和监控 界面展示: 创建 shell 脚本文件: touch menu.sh touch index.sh touch welcome.sh 赋予脚本文件可执行权限: chmod a+x menu.sh index.sh welcome.sh menu.sh#!/bin/bash #menu.sh function menu() title=My Home name=Randy time=date +%Y-%m-%d cat qaz # # #*echo -e e。

2、32m $title eOm* # # # # 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 。

3、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 e32m$stre0m 3) r。

4、ead -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=$names password is set successfully echo -e 03330;47$str0330m else str=$names password is set failly! echo -e 03331;47m$str0330m fi read -p delete the user: name u。

5、serdel -r $name /dev/null if $? -eq 0 ;then str=user $name is delete successfully! echo -e 03330;47m$str0330m else str=user $name is delete failly! echo -e 03331;47m$str0330m fi 5) str=df -Th echo -e 03330;47m$str0330m 6) str=free -m echo -e 03330;47m$str0330m clear menu echo -e e31mLogout .e0m slee。

6、p 1 break 9) echo -e e31mQuit successfully!e0m exit *) str=Input error please re-enter echo -e 03330;47m$str0330m esac done 5.welcome.sh#!/bin/bash #welcome clear echo -e e31mWelcomee0m 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 e31m$stre0m sleep 2 . index.sh index else fi str=Login failly echo -e e31m$stre0m fi done。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值