A place for Unix Thoughts and Ideas

Adding multiple service accounts users in loop form

Here is nifty example of using multiple fields in a for loop.

As part of the build process for some of my systems, I need to add multiple accounts at the same time.

I could write this out every time, but this stub makes it easy and it can be reused when I get requests in the future.

for users in \
“u=oradev6 i=6048 ga=oinstall g=dba proj=group.dba”\
“u=oradev7 i=6049 ga=oinstall g=dba proj=group.dba”;
eval $users
useradd -u $i -g $g -G $ga -d /export/home/$u -s /bin/bash -c “$u User” -m $u
passwd -N $u

usermod -K project=$proj $u

echo $u >> /etc/cron.d/cron.allow


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: