创建普通用户

3 阅读1分钟
# username
USER=test
# user settings
adduser $USER
echo '<replace_your_password>' | passwd --stdin $USER
chown -R $USER:$USER /data
echo "[INFO] add user and set permission finish"


# set sudo 

perm_line="$USER   ALL=(ALL)    NOPASSWD: ALL"

if grep -qF "$perm_line" /etc/sudoers; then
   echo "[INFO] $USER already have sudo perm"
else
   echo "$perm_line" | tee -a /etc/sudoers 
   echo "[INFO] add $USER to sudoers"
fi