Here's the script code I'm using now:
getent group $MYGROUP if [ $? -ne 0 ] ; then sudo su -c "groupadd $MYGROUP" fi sudo su -c "useradd mynewuser -p mypassword -m -g $PRIMARYGRP -G $MYGROUP"
This approach works well on openSuse. But there are several problems with the user account it creates on Ubuntu so I am seeking help here.
- the terminal prompt isn't set (
echo $PS1returns nothing)
- the arrow keys and tab key do not work correctly in the terminal
- the password doesn't seem to work (although I'm still unclear exactly what this issue is)
- the /etc/sudoers rights set for this new user are not honored
If instead I manually create the user with
adduser (instead of useradd) I don't have these problems on Ubuntu. But I can't use
adduser on openSuse (afaik). Therefore, I need a non-Debian-exclusive script or method of adding user accounts via my bash script that works on Ubuntu (and doesn't stop working on other distros).
Finally, I would like to understand the differences between
useradd. For example, I want to know which skeleton directory is used by
adduser as that might be the reason
useradd isn't working as expected (because I just accepted the default).