Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 05-18-2004, 08:08 AM   #1
LQ Newbie
Registered: May 2004
Posts: 4

Rep: Reputation: 0
Unhappy create users using script

hi... I need to create many user on my redhat 9, so its unpractical to ceate one by one, so how can I create many user using script that can read from a source file, should I use perl script??? or bash script?? have someone written it...please help me...
Old 05-18-2004, 08:19 AM   #2
Senior Member
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 59
Try this....

The file /home/names.txt has the user names (lower case) , groups and the Linux/Samba password.
The Linux and Samba passwords are the same and the user should change them soon after login.
The groups can already exist.

For example.....

fred service 12qwaszx
sam hr 34erdfcv
joe maint 56tyghbn
sally sales 78uijkm

# Ensure that root is running the script.
if [ $WHOAMI != "root" ]; then
echo "You must be root to add news users!"
exit 1

cat ${NEW_USERS} | \
while read USER GROUP SMBPASS ; do
   groupadd ${GROUP} 2> /dev/null
   adduser ${USER} -g ${GROUP}

   (echo $SMBPASS; echo $SMBPASS) | passwd --stdin ${USER} > /dev/null
   echo Added user ${USER}

   smbpasswd -e ${USER} -w ${SMBPASS} > /dev/null
   (echo $SMBPASS; echo $SMBPASS) | smbpasswd -as ${USER}
   echo -e "${USER} = ${USER}" >> /etc/samba/smbusers

Last edited by homey; 04-05-2005 at 02:33 PM.


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 On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
create new users in squirellmail bharath144 Linux - Software 1 11-26-2005 03:02 PM
perl script help required to create users and changing the owner to pericular folder sridhar11 Programming 2 10-25-2005 02:16 PM
Can't create users! Zeke55 Linux - Newbie 9 12-08-2004 01:23 PM
Create users in Samba br_sriram Linux - Software 2 09-24-2004 11:49 AM
I cant create functional users! bcf2 Mandriva 4 08-31-2004 08:58 AM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:48 AM.

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