The script below is what I have tried already but it still asked me for the user's password and other information when it ran.
#!/bin/bash
PASSWORD="somepassword"
USERNAME="default"
if id -u "$USERNAME" >/dev/null 2>&1; then
userdel -r -f $USERNAME
adduser --disabled-password --gecos "" $USERNAME
usermod -a -G sudo $USERNAME
echo $USERNAME:$PASSWORD | chpasswd
else
adduser $USERNAME
adduser --disabled-password --gecos "" $USERNAME
usermod -a -G sudo $USERNAME
echo $USERNAME:$PASSWORD | chpasswd
fi
adduser $USERNAME
(in theelse
block - without the non-interactive options) doing there? – steeldriver Feb 09 '17 at 23:11