LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-09-2020, 09:35 AM   #1
Fred27377
Member
 
Registered: Jun 2020
Posts: 68

Rep: Reputation: Disabled
Batch adding multiple users to an instances for multiple pages


Hello:

I would like to add a hundred at a time. Random user name and password. I have had some succcess with Useradd . I am using fedora 32 server. Any help would be great!
 
Old 06-09-2020, 10:04 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,680

Rep: Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971
Quote:
Originally Posted by Fred27377 View Post
Hello:
I would like to add a hundred at a time. Random user name and password. I have had some succcess with Useradd . I am using fedora 32 server. Any help would be great!
Ok, we'll be glad to help, but you have given us next to NO details at all. You don't say what success you've had, what you've done/tried so far, what parameters you want for user names/passwords, etc.

This very much sounds like a homework question; 'random user name and password'?? One hundred users? Show us what you have done/tried so far, and tell us where you're stuck. Otherwise, read the "Question Guidelines" link in my posting signature, along with the LQ Rules about homework questions, and reference any of the MANY bash-scripting tutorials you can find to get you started.
 
1 members found this post helpful.
Old 06-09-2020, 12:27 PM   #3
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,803

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
Quote:
Originally Posted by Fred27377 View Post
... multiple users to an instances for multiple pages
What does that even mean? Can you clarify that?

Adding users via a batch process has been getting done on UNIX systems for decades and on Linux for, well, decades. I'd be astonished if something didn't come up from a Google search. Let's see ... googling "adding multiple users in linux" ...
Code:
About 73,900,000 results (0.49 seconds)
Try it.
 
1 members found this post helpful.
Old 06-09-2020, 12:37 PM   #4
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
For starters, have a look at this thread. A tool that was mentioned there, newusers, may be helpful. But you really should provide more details. You said you have had some success with useradd. So what exactly have you tried? What worked? What didn't work?

"Random user name and password" sounds strange. Should they be read from a file? Or generated on the fly? And how the users are supposed to login then? Anyway, search for a "wordlist generator", there are lots of them, maskprocessor, statsprocessor, cupp, crunch, CeWL, princeprocessor, etc. There are also many password generation tools: gpw, pwgen, apg, makepasswd, mkpasswd.pl, goxkcdpwgen, etc. There are also some tools for generating OTPs: otp, rotp.
 
1 members found this post helpful.
Old 06-09-2020, 01:07 PM   #5
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,803

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
Quote:
Originally Posted by shruggy View Post
For starters, have a look at this thread. A tool that was mentioned there, newusers, may be helpful. But you really should provide more details. You said you have had some success with useradd. So what exactly have you tried? What worked? What didn't work?

"Random user name and password" sounds strange. Should they be read from a file? Or generated on the fly? And how the users are supposed to login then? Anyway, search for a "wordlist generator", there are lots of them, maskprocessor, statsprocessor, cupp, crunch, CeWL, princeprocessor, etc. There are also many password generation tools: gpw, pwgen, apg, makepasswd, mkpasswd.pl, goxkcdpwgen, etc. There are also some tools for generating OTPs: otp, rotp.
I've done this in the past using a plain ol' ASCII file, a shell script, and expect long before "newusers" was available. It's hardly rocket science and is probably more portable (across flavors of UNIX, at least). You do have to learn something (Expect is kind of fun to use), though, instead of praying that someone's already created a magic command that does everything you want.

As for the random string generation: even that could be done in a shell script. I have an ancient C program called "monkey" (as in "roomful of monkeys banging on typewriters"; it's never created anything even close to Shakespeare, though) that generates random-length words, sentences, and paragraphs that could be modified for the usernames though, IMHO, a random lookup in a couple of lists -- one with first names, a second with last names -- would work for that.

There are lot of ways to skin this cat---the OP needs to sit down and think about it for a bit.

If this is a homework problem, I'd be interested in knowing what the students were expected to know by this point in the class.

Cheers, all...
 
1 members found this post helpful.
Old 06-10-2020, 02:30 PM   #6
Fred27377
Member
 
Registered: Jun 2020
Posts: 68

Original Poster
Rep: Reputation: Disabled
Thank you all for responding! I used an if statement with the else being
Add user name. I wanted to randomize the name and the password. I had trouble
Using crypt and add user because add user pauses in execution. I should have kept some of my notes. It is really just an idea. I should have thought it through.
 
Old 06-10-2020, 02:48 PM   #7
Fred27377
Member
 
Registered: Jun 2020
Posts: 68

Original Poster
Rep: Reputation: Disabled
root# useradd -d / -g users -p $(perl -e'print crypt("foo", "aa")') -M -N foo
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a batch of new users and adding ssh keys using a script mattjjs Linux - Newbie 5 02-13-2014 10:46 AM
[SOLVED] how to write a batch file in linux?and what are batch(.bat) file benefits? karthilin Linux - Newbie 8 10-15-2012 02:10 PM
Bash script for adding users is running but not adding users Gren Programming 2 04-27-2012 03:53 AM
sendmail-2: Wrong number of instances of process sendmail:, expected instances equal maxymaxymaxymaxymaxy Linux - Newbie 1 06-15-2011 10:51 AM
kickstart; how-to info needed for multiple instances of RH OS's and multiple unique v Joe_Wulf Linux - Server 4 06-21-2007 11:18 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:48 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration