Recently, I have just started to learn linux and I am currently trying to make a shell script that can automate the task of creating user accounts, assigning them passwords and then assigning them to groups.
I have got so far as being able to create the user account and creating a random password for them by using file descriptors, but have no idea of how I can automatically assign them to a group.
If it matters I am using the Raspberry Pi.
The code I have so far is:
exec 3< users.txt
exec 4< passwords.txt
while read iuser <&3 && read ipasswd <&4 ; do
adduser $iuser
echo $ipasswd | passwd --stdin $iuser
done