The lazy programmer scripts
scripts that work

Lazy create sudo user GitHub

Creating users on Linux is trivial, but creating a user with sudo rights and no password confirmation when using sudo is not.

The script must be run under user root.

Tested on Ubuntu, Debian, CentOS and RHEL.

#!/bin/bash
set -xe

USERNAME="kami"
useradd -m -s /bin/bash $USERNAME
usermod -aG sudo $USERNAME || true # for Debian/Ubuntu
usermod -aG wheel $USERNAME || true # for CentOS/RHEL

# this change is better done manually using "visudo -f /etc/sudoers"
echo "${USERNAME} ALL = NOPASSWD : ALL" >> /etc/sudoers

That's all, folks!

Written by kami on Friday December 8, 2017
Permalink - Tags: bash, linux, ubuntu, rhel, centos

Leave a comment

comments powered by Disqus

« Lazy show Windows volume information - Lazy mine webdollar in terminal »