LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-17-2009, 07:03 AM   #1
asifbasha
Member
 
Registered: Feb 2009
Posts: 98

Rep: Reputation: 15
how to add bulk of users in fedora 10


hai to all
i suppose to add a bulk of users in my linux system and i am the root user,i have tried the useradd command it prompts for a password for each user.Each and every time typping the new password and verifying that new password for new user makes me difficult ,what i thought is that i want to fetch username and password form text file or bash script to create all users with out giving input to command line such as passwd command ...is this possible for me by using a bash script , and if i execute that bash script ./scriptname all users have to be created ,is that possible ? if so please help me ..

thanks in advance
 
Old 08-17-2009, 09:07 AM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,398
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
In most cases, the passwd command and it's ilk do not read from stdin to read passwords, which makes your approach difficult or impossible. If your user database already exists on one or more other hosts, you can simply copy & paste to the /etc/passwd and /etc/shadow files.

--- rod.
 
Old 08-17-2009, 03:55 PM   #3
slimm609
Member
 
Registered: May 2007
Location: Chas, SC
Distribution: slackware, gentoo, fedora, LFS, sidewinder G2, solaris, FreeBSD, RHEL, SUSE, Backtrack
Posts: 430

Rep: Reputation: 67
just a quick and dirty script to do that for you.
Check and make sure that passwd accepts the --stdin option. (RHEL4,5 does). Dont have a F11 box built right now to test.

Code:
#!/bin/bash

USERFILE=/root/user.list

cat $USERFILE | while read line ; do
  USER=`echo $line | awk '{ print $1 }'`
  PASS=`echo $line | awk '{ print $2 }'`
  useradd -d /home/$USER $USER
  echo "$PASS" | passwd --stdin $USER
done

the file should contain

user1 password1
user2 password2
user3 password3

Last edited by slimm609; 08-17-2009 at 04:05 PM. Reason: made a correction
 
Old 08-18-2009, 08:09 PM   #4
rfelsburg
Member
 
Registered: Nov 2008
Posts: 52

Rep: Reputation: 18
You can just easily use perl's crypt command to hash the password, and then useradd's -p option to specify the password. Depends on which you're more comfortable with.

-Rob
 
  


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
Setting Disk Quota for Bulk Users haariseshu Linux - Server 3 06-10-2009 08:51 AM
Bulk user add script haariseshu Linux - Server 40 01-15-2009 09:06 AM
add several users - fedora C4 xchido Fedora 1 02-07-2006 08:41 AM
Add bulk users at a same time mudasar Linux - Networking 1 11-20-2005 01:56 PM
Mail Setup for Bulk Users thadco Linux - Newbie 1 06-25-2005 01:24 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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