Score:0

Create multiple users off a script

cn flag

I know this is an old topic but I am struggling to find an answer.

Every 4 months I have to create 150 new users with a password, and have them added to default groups with a working home directory every 4 months.

But this command

sudo adduser testuser02 --disabled-password && sudo passwd testuser02 testpassword02

stops and asks questions for Full Name, Room Number, Work Phone, Home Phone, Other and "Is the information correct?"

Having to press ENTER six times is not how I want to do this!

Also the passwd command fails.

I want to use adduser because it creates the home folder and groups (access permissions) properly.

I know useradd does a similar thing but I am struggling to make it do what I need.

cocomac avatar
cn flag
Why again do you need to create exactly 150 users every four months. That seems like a bit of an odd task
Sadaharu Wakisaka avatar
pl flag
Welcome to AskUbuntu, https://askubuntu.com/questions/94060/run-adduser-non-interactively this answer does it without asking questions.
skris88 avatar
cn flag
Thanks, please close this request. We are a training organisation with a 3 month long course and have about 150 new remote students every time; and - anyway - the command is: username=test4 && password=test4 && sudo adduser --gecos "" --disabled-password $username && sudo chpasswd <<<"$username:$password" which I script via a spreadsheet with each student's login ID being their firstname.lastname and their login PW being set to FirLasDDMM eg. Jill Smith born 12/29 PW will be JilSmi2912 - and there is pre-verification on the spreadsheet that there are no duplicates of IDs or PWs.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.