LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-11-2007, 04:32 AM   #1
bczm8703
LQ Newbie
 
Registered: Jun 2007
Posts: 4

Rep: Reputation: 0
Exclamation Automate user account creation


i have being task to create 100 users... i am able to create the user login name.. but now i have to create the password for these accounts... the solution i found on this forums does not seems to solve my problem... could some one help me??

my script is

Code:
for((i=0; i<=100; i++))
do
useradd -m user$i -u 180$i -g Admin -d /home/user$i -s /bin/sh -c 'User'$i
done
 
Old 06-11-2007, 04:39 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
you can use chpasswd to change passwords in bulk.
 
Old 06-11-2007, 09:44 AM   #3
bczm8703
LQ Newbie
 
Registered: Jun 2007
Posts: 4

Original Poster
Rep: Reputation: 0
Exclamation

sorry can i ask how do i use this command inside the script???

i want the whole process to be fully automated.. the user should not be ask to enter anything...
thanks in advance...

Last edited by bczm8703; 06-11-2007 at 09:48 AM.
 
Old 06-11-2007, 09:47 AM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
well you'd just insert it after the useradd command.
 
Old 06-11-2007, 09:53 AM   #5
bczm8703
LQ Newbie
 
Registered: Jun 2007
Posts: 4

Original Poster
Rep: Reputation: 0
sorry i think my question is not clear or there is a misunderstanding...
can i know the command structure??? cos by putting chpasswd still require the user to input the username and password... what i need is that the user or administrator do not need to enter anything.. he only need to run the script....
 
Old 06-11-2007, 10:38 AM   #6
brianmcgee
Member
 
Registered: Jun 2007
Location: Munich, Germany
Distribution: RHEL, CentOS, Fedora, SLES (...)
Posts: 399

Rep: Reputation: 40
In [1] you can read how pipes can be used efficiently. Then this should be easy:

Code:
echo username:password |chpasswd
You can also pipe a list of login data. Each line should include a username and password seperated by a colon.

[1] http://www.tdl.com/~netex/linux-doc-...e/node122.html
 
Old 06-12-2007, 09:20 PM   #7
bczm8703
LQ Newbie
 
Registered: Jun 2007
Posts: 4

Original Poster
Rep: Reputation: 0
Exclamation

just to confirm.. the full code will be as follow

Code:
for((i=0; i<=100; i++))
do
useradd -m user$i -u 180$i -g Admin -d /home/user$i -s /bin/sh -c 'User'$i
echo user$i:pass$i |chpasswd
done
 
  


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
Rhythmbox- Writing a Program to Automate Playlist Creation RevenantSeraph Linux - Software 1 04-16-2007 02:39 AM
Doubt in super user account creation with SUSE-10.0 tcegrid Linux - General 1 04-06-2007 06:06 AM
LXer: Speaking Unix, Part 6: Automate, automate, automate! LXer Syndicated Linux News 0 01-04-2007 09:54 AM
is it legitimate and allowed and can be done to make another user account set uid and gid to null 0 to make another root account with different name and possibly not damage the debian system creating and using that new account BenJoBoy Linux - Newbie 12 01-29-2006 10:02 AM
automatic user account creation in mail server kar11 Linux - Software 0 04-13-2004 11:55 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:21 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