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
posted @ 2020-11-05 10:59  名字很长容易被惦记  阅读(134)  评论(0编辑  收藏  举报