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

常用bash,autoUserAdd.sh

时间:2017-02-26 23:47:39      阅读:187      评论:0      收藏:0      [点我收藏+]

标签:pre   username   ini   passwd   put   exit   swa   bash   bsp   

#!/bin/bash
# auth: xiluhua
# date: 2017-02-26
 
read -p "please input a username:" username
[ -z $username ] && echo "a username is needed" && exit 2
 
if id $username &> /dev/null
then
    echo $username is exist
fi
 
read -p "please input the passward:" passward
[ -z $passward ] && echo "a passward is needed" && exit 3
 
useradd $username
echo "$passward" | passwd --stdin $username &> /dev/null
echo "add $username finished"

 

常用bash,autoUserAdd.sh

标签:pre   username   ini   passwd   put   exit   swa   bash   bsp   

原文地址:http://www.cnblogs.com/xiluhua/p/6456120.html

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