码迷,mamicode.com
首页 > 其他好文 > 详细

删除和创建用户的脚本

时间:2015-12-01 19:39:32      阅读:150      评论:0      收藏:0      [点我收藏+]

标签:删除和创建用户的脚本

#!/bin/bash

#创建和删除用户,创建的用户默认密码为123456

user=(/etc/passwd)

echo "**************Configure Menu***************"

echo "** 1.Create User                         **"

echo "** 2.Delete User                         **"

echo "*******************************************"

read -p "Please enter the number:" vlan

case $vlan in

1)

sleep 1

for vlan in $user

do

read -p "Please enter to create the user": user

useradd $user |echo "123456" |passwd --stdin $user

if [ $? -le 0 ]

then

sleep 1

        echo "Creating a successful!"

fi

done

;;

2)

sleep 1

for vlan in $user

do

read -p "Please enter the user to delete": user

userdel $user

if [ $? -le 0 ]

then

sleep 1

        echo "Delete the success!"

fi

done

esac 



判断用户的密码过期时间


#!/bin/bash

#判断用户名的密码过期时间

vlan=$(cat /etc/login.defs |grep --color=auto PASS_MAX_DAYS |grep -v ^# |awk ‘{print $2}‘)

if [ $vlan -gt 60 ]

then

sleep 1 

echo "Password expiration time:$vlan days!"

else

echo "Password expiration time$vlan days!"

fi


本文出自 “sunshineboy” 博客,请务必保留此出处http://sunshineboy.blog.51cto.com/10310940/1718594

删除和创建用户的脚本

标签:删除和创建用户的脚本

原文地址:http://sunshineboy.blog.51cto.com/10310940/1718594

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!