This is what I'm trying to do in a script. It works here manually, but prompts me for a password. How do I:
- Create a new user
- With sudo privs
- Switch to that user
Continue executing the rest of the script
sudo adduser centos sudo passwd centos usermod -aG wheel centos sudo su centos
I have tried the following but in Centos 7 bash, --disabled-password and -gecos both say "option not found."
adduser --disabled-password --gecos "" username
--disabled-password. That would let anyone access that user account without a password.adduser-- you'd have the same problem with CentOS 7 runningadduserfrom any other shell, or running it without a shell at all (ie. withsubprocess.Popen(['adduser', ...], shell=False)in Python).