add group if doesn't exist bash code example
Example 1: usermod: group 'sudo' does not exist
usermod - aG wheel username #in centos7
Example 2: bash if user exists in a group then add
egrep -i "^useraccount:" /etc/passwd;
if [ $? -eq 0 ]; then
echo "User Exists"
else
echo "User does not exist -- Invalid Username"
fi