I have a single computer for our building which various building residents need to be able to log into with their own names. I have a listing of all the usernames (over 300 users) and passwords in a text file. I did some research and found that it should be possible to add them using a script, but there were so many changes whenever a possible script was posted that I had trouble following the message threads to get a coherent final script to use.
So far, here is what I have found, and I hope this works in Suse 11.3:
But it doesn’t say anything about adding to more than one group? I know if I add thru YAST, it adds to users, and then by default adds to the additional group “video” (is this for them to be able to log in with the gui?)
However, the script I found shows one user group, but didn’t say what to do if I needed to add to more than one group? Or will adding these users via the list auto-add them to video because of the default in YAST? Or do I need to put both groups, maybe comma-separated or something?
I am a mostly newbie here, and I really don’t do code, but I can follow directions if they’re explained well enough! lol!
Here’s what I found:
Use chmod command:
# touch /root/batch-user-add.txt
# chmod 0600 /root/batch-user-add.txt
Create a user list as follows. Open file:
# vi /root/batch-user-add.txt
Append username and password following the format provided of:
loginname:password:uid:gid:comment:home_dir:shell
*** does this mean simply copy/paste the below user info into the batch-user-add.txt file?
also, what happens if you don’t define shell? and which shell is better?
Unit0106:concorderesident:1201:1001:Unit 106:/home/Unit0106:/bin/bash
Unit0107:concorderesident:1202:1001:Unit 107:/home/Unit0107:/bin/bash
Unit0108:concorderesident:1203:1001:Unit 108:/home/Unit0108:/bin/bash
Unit0109:concorderesident:1204:1001:Unit 109:/home/Unit0109:/bin/bash
Unit0201:concorderesident:1205:1001:Unit 201:/home/Unit0201:/bin/bash
Unit0202:concorderesident:1206:1001:Unit 202:/home/Unit0202:/bin/bash
Unit0203:concorderesident:1207:1001:Unit 203:/home/Unit0203:/bin/bash
Unit0204:concorderesident:1208:1001:Unit 204:/home/Unit0204:/bin/bash
Unit0205:concorderesident:1209:1001:Unit 205:/home/Unit0205:/bin/bash
Unit0206:concorderesident:1210:1001:Unit 206:/home/Unit0206:/bin/bash
Unit0207:concorderesident:1211:1001:Unit 207:/home/Unit0207:/bin/bash
Unit0208:concorderesident:1212:1001:Unit 208:/home/Unit0208:/bin/bash
Unit0209:concorderesident:1213:1001:Unit 209:/home/Unit0209:/bin/bash
Unit0210:concorderesident:1214:1001:Unit 210:/home/Unit0210:/bin/bash
Unit0301:concorderesident:1215:1001:Unit 301:/home/Unit0301:/bin/bash
Unit0302:concorderesident:1216:1001:Unit 302:/home/Unit0302:/bin/bash
Unit0303:concorderesident:1217:1001:Unit 303:/home/Unit0303:/bin/bash
Unit0304:concorderesident:1218:1001:Unit 304:/home/Unit0304:/bin/bash
Unit0305:concorderesident:1219:1001:Unit 305:/home/Unit0305:/bin/bash
Unit0306:concorderesident:1220:1001:Unit 306:/home/Unit0306:/bin/bash
Now create users in batch:
# newusers /root/batch-user-add.txt
Ok, this seems fairly straightforward so far, and the command line doesn’t intimidate me too much, as I grew up on DOS. :\
Can someone tell me if I’m doing this right? And if I need to worry about whether it’s only adding to the group “users” and not to “video” ? Or how to add to both?
and final question, a quick way to set all those newly created users to require them to change their password on first login, and then to never have the password expire afterwards? (hopefully without resetting my root password in the process?)
Any help on this is greatly appreciated! Thanks!