linux服务器添加普通账户脚本
linux服务器添加普通账户脚本
添加用户,设置密码,添加sudo
#!/bin/bash
id $1 >& /dev/null
if [ $? -ne 0 ]
then
useradd $1
echo "password is :$1@ict.ac.cn"
echo $1:$1@ict.ac.cn | chpasswd
else
echo "user already exists!"
fi
echo "加入docker组"
gpasswd -a $1 docker
egrep "^$1" /etc/sudoers >& /dev/null
if [ $? -ne 0 ]
then
echo "写入sudo权限"
echo "$1 ALL=(ALL) ALL" >> /etc/sudoers
else
echo “已有sudo权限”
fi
echo "验证"
cat /etc/sudoers |grep dong
---------------------------------------------------------
恐惧是因为努力的还不够,加油 ~~---------------------------------------------