LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 12-13-2011, 10:54 AM   #1
jayakumar01
Member
 
Registered: Nov 2011
Posts: 106

Rep: Reputation: Disabled
How can i create multiple user with password in single line


Hi All,
How can i create a multiple useracc with password assign in single line
i searched out google i find out the below comand which is used to assigning username password for single user .

echo "username : password" | newusers

Last edited by jayakumar01; 12-13-2011 at 10:56 AM.
 
Old 12-13-2011, 01:49 PM   #2
cmnorton
Member
 
Registered: Feb 2005
Distribution: Ubuntu, CentOS
Posts: 585

Rep: Reputation: 35
Semicolon ;

Separate the commands with a semicolon (. Other than that I don't know of a batch way to load new users into a Linux system, unless you hack the password file. From you example, you'd load an output shell script file up with adduser commands.

Last edited by cmnorton; 12-13-2011 at 01:50 PM. Reason: Add more detail.
 
Old 12-14-2011, 05:53 AM   #3
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,460

Rep: Reputation: 1552Reputation: 1552Reputation: 1552Reputation: 1552Reputation: 1552Reputation: 1552Reputation: 1552Reputation: 1552Reputation: 1552Reputation: 1552Reputation: 1552
webmin (Google for it!) has the ability to create/update multiple users through a web interface, I've used it to replicate user accounts on 20+ servers. It's a bit of effort putting the usernames, password, etc. into the right format but it's a damn lot quicker than doing them one by one.
 
Old 12-14-2011, 07:20 AM   #4
Reuti
Senior Member
 
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 15.2
Posts: 1,339

Rep: Reputation: 260Reputation: 260Reputation: 260
I didn’t know about the newusers command, but when it works for you it’s fine. What you need is a loop reading the file with the predefined users/passwords and feed it to the newusers command.
 
Old 12-14-2011, 11:31 PM   #5
shridhar005
Member
 
Registered: Jul 2008
Posts: 90

Rep: Reputation: 17
Write a script for it.
If you have some doubt about it,just let me know.
Did not get that single line concept at all.
 
Old 12-15-2011, 04:05 AM   #6
linuxrndblog
Member
 
Registered: Oct 2010
Location: India
Posts: 89

Rep: Reputation: 2
Dear jayakumar01,

Try newusers command. but you check manual of this command before use.
 
Old 12-16-2011, 01:25 AM   #7
jayakumar01
Member
 
Registered: Nov 2011
Posts: 106

Original Poster
Rep: Reputation: Disabled
hi,
useradd $1

p1=$(</dev/urandom tr -dc A-Za-z0-9 | head -c6) ; echo $p1

echo "$1:$p1" | chpasswd

i tried out by using genpasswd generator .But I Want to know whether its possible in linux by obtaining in single line are not. i Got these three question from a yahoo interveiwer .

As same as there is any possible to make multiple directory in a single command,these was another question im tring out but i could int.

mkdir -p /one/two/three/four
inside of one i require to obtain four directory,

How does ps aux command works on background.

Can some one know any one of these .pls help me out im checking out following three things in google i never find a direct answer to it .thus it i posted out in here to get answer from linux expert.

Last edited by jayakumar01; 12-16-2011 at 01:39 AM.
 
Old 12-16-2011, 05:16 AM   #8
shridhar005
Member
 
Registered: Jul 2008
Posts: 90

Rep: Reputation: 17
Q. How to create multiple directories recursively with single command?
Ans:
Quote:
user@localhost$ mkdir -p dir1/{dir2,dir3,dir4}/
Will create dir2,dir3,dir4 under dir1 i,e at second level down there will be three directories.
case2:
Quote:
user@localhost$ mkdir -p dir1/{dir2,dir3,dir4}/{dir5,dir6}
This will create one dir1 at level1,
then three directories dir2,dir3,dir4 at level 2,
then two directories dir5,dir6 under each of level 2 directory i.e dir2, dir3,dir4

dir1/
dir2/ dir3/ dir4/
dir5/ dir6/ dir5/ dir6/ dir5/ dir6/

Do you have any idea regarding bash shell's abilities? If not please go through the bash reference manual.

Q. Creating multile users with single line?
Ans. write a simple for loop. It is one liners.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 multiple user in multiple linux boxes from single remote host niaz_ph Linux - Newbie 3 09-12-2011 03:48 PM
multiple pattern search in a single file line by line saheervc Linux - Newbie 2 09-01-2010 11:45 PM
[SOLVED] BASH: create user and password on multiple machines hobbes80 Programming 7 08-11-2010 10:15 AM
how to create a single line of output from multiple variable lines of input steven.c.banks Linux - General 2 02-03-2010 03:09 PM
SED how to find multiple patterns on a single line yaazz Programming 9 07-31-2009 04:20 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 05:40 AM.

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