Mass add users


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Mass add users
# 1  
Old 03-24-2010
Mass add users

Anyone has a script or something that can do this? I have a list of about 500 users and I need to add them to an AIX box. The profiles should have "Full Name" and "User Name".
# 2  
Old 03-24-2010
In AIX you can use the "mkuser" command. If you have a simple list of users in a text file, one username per line, this is as trivial as a for loop.

Something like:

for user in `cat userlist.txt`; do
mkuser $user blah blah blah
done
# 3  
Old 03-24-2010
I tried using something like below, but I need to also include the "User Info" as well as the username in the user properties.

EDIT: The below code worked. The key here is to have a text file that has no spaces and ";" for separators.

Code:
#!/bin/ksh
x() {
   LIST=
   SET_A=
   for i in "$@"
   do
           if [ "$i" = "admin=true" ]
           then
                   SET_A="-a"
                   continue
           fi
           LIST="$LIST \"$i\""
   done
   eval mkuser $SET_A $LIST
   }
filename=/path/to/text/file
  cat ${filename} | \
   while read FULLNAME USERID
   do
 x pgrp='pgrp' groups='group1,group2' home='/home' shell='/usr/bin/bash' gecos='$FULLNAME' $USERID
done



---------- Post updated at 10:47 PM ---------- Previous update was at 05:56 PM ----------

BTW - this was for AIX.

Last edited by bbbngowc; 03-24-2010 at 11:46 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

I need to add 30 users to 50 servers

Hi Y'all, I need help adding 30 users to 50 servers. Is there a way to automate this? I'm using this command: sudo mkuser pgrp=srvadm gecos=Spears, Brittney auditclasses=ALL sugroups=system,security user01 But I'm doing it per user, per server...HOW CAN I MAKE THIS EASIER?... (7 Replies)
Discussion started by: jennie28n
7 Replies

2. Red Hat

How to add a new users in proftpd server?

Hi, I have installed proftpd server in my amazon instance and how to enable a new user to access the proftpd. 1. How to add or delete a users 2. how to enable a particular user to access particular folder Regards Paulwintech (5 Replies)
Discussion started by: Paulwintech
5 Replies

3. UNIX for Dummies Questions & Answers

script to add 10000 users

Hi All i have written the script to add 10000 users, when i execute the script it had no errors ,but the script is not adding the users. pls correct me. i want it using while loop #!bin/sh count=0 while do useradd username$count count=`expr $count + 1` done ~ (2 Replies)
Discussion started by: kalyankalyan
2 Replies

4. OS X (Apple)

Help: Add email users in OSX terminal

Please forgive me if this is the wrong place to post. I am a VERY basic user here and have been tasked with adding a user to our email system -- we use a squirrelmail interface and I have root passwords etc. I tried logging in through a browser but get this error: ERROR: Connection... (1 Reply)
Discussion started by: dperro01
1 Replies

5. Solaris

How to add multiple users

HI, 1.I want to add multiple users at a same time. How to achive this , since useradd will add only one user at a time,. 2.Also let me know how to install a software in a group of machines where the machines are not configured as zones (1 Reply)
Discussion started by: rogerben
1 Replies

6. Solaris

Add environment variables for all users

hi I need to add environment variables for all users and make them available when they login. I don't know which file to edit. Also these variables should be displayed when "env" command is executed. Please help....which file is common for all users, without editing their specific .profile or... (2 Replies)
Discussion started by: ashish_uiit
2 Replies

7. Shell Programming and Scripting

Need Script to Validate and Add more users one time

I need a script to validate and add more than one user at one time Field 1 - FirstName LastName Field 2 - userid Field 3 - email address Field 4 - department Validation for Field 1 No... (3 Replies)
Discussion started by: karthikn7974
3 Replies

8. Shell Programming and Scripting

command to add users to group

does a command exist to add users to more than one group? i think the usermod command can do this but i'm not really sure. past ways of me doing this has always been to just hack the /etc/group file and put the user in whatever group i need him to be in. however, vi..ing files like /etc/groups... (2 Replies)
Discussion started by: Terrible
2 Replies

9. AIX

VI questions : mass changes, mass delete and external insert

Is it possible in VI to do a global change but take the search patterns and the replacement patterns from an external file ? I have cases where I can have 100,200 or 300+ global changes to do. All the new records are inside a file and I must VI a work file to change all of them. Also, can... (1 Reply)
Discussion started by: Browser_ice
1 Replies

10. Shell Programming and Scripting

How to add users using Shell Scripting

I am on Fedora 4 and using VI. I need to add users from a text file. ANYONE? plz help me out here. I am already going bald, dont need anymore hair to fall out. Joshua (2 Replies)
Discussion started by: Neece29
2 Replies
Login or Register to Ask a Question