User Accounts


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting User Accounts
# 1  
Old 02-15-2004
Question User Accounts

I have found a script to create user accounts. But there are a few lines i dont understand. Can someone help me with this? Here's the code:

######################################

while [ $TOTAL -gt 0 ];
do
ACCT=${USER_ACCT}${START}
START=`expr $START + 1`
START=`echo ${START} | awk '{printf("%02d",$1)}'`
TOTAL=`expr $TOTAL - 1`
useradd -g ${GROUP_ID} -d ${TOP_LEVEL_DIR}/${ACCT} -c 'Student Acct' -m -s /bin/ksh ${ACCT}
(cd ${TOP_LEVEL_DIR}/coursefiles; tar cf - . | (cd ${TOP_LEVEL_DIR}/${ACCT}; tar xf -))
chown -R ${ACCT} ${TOP_LEVEL_DIR}/${ACCT}
chgrp -R ${GROUP_ID} ${TOP_LEVEL_DIR}/${ACCT}
chmod 755 ${TOP_LEVEL_DIR}/${ACCT}
echo "Account ${ACCT} created."
echo
done


ACCT=${USER_ACCT}${START_SAV}
echo "Enter the default password to use for the recently created accounts"
echo
passwd ${ACCT}
PASSWORD=`grep '^'${ACCT}':' /etc/shadow |cut -d: -f2`

START=`expr $START_SAV + 1`
START=`echo ${START} | awk '{printf("%02d",$1)}'`
TOTAL=`expr $TOTAL_SAV - 1`

while [ $TOTAL -gt 0 ];
do
ACCT=${USER_ACCT}${START}
ed /etc/shadow <<EOF
g/${ACCT}:/s/:\*LK\*:/:${PASSWORD}:
W
Q
EOF
START=`expr $START + 1`
START=`echo ${START} | awk '{printf("%02d",$1)}'`
TOTAL=`expr $TOTAL - 1`
done

######################################

Thanks!!!
# 2  
Old 02-15-2004
Is this homework, Sensor?

Which part(s) exactly do you want to know about? The "while .... done" parts are loops. Most of the code you listed is assigning values to variables and running commands that you could easily figure out by typing "man chown", "man chmod", etc at a prompt.
# 3  
Old 02-16-2004
Data

The Do while loops & the echo's i really understand, i'm not that stupid Smilie
I just want to know what the 2 bloks do...
# 4  
Old 02-16-2004
1) you dont have do while loops. you only have while loops. (at least in your script.)

2) from a glance at the commands and files used you are createing user and setting up their passwords.

you will understand the script alot more if you read the man pages for the commands used.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. OS X (Apple)

Thunderbird user accounts

Hi All I am trying to find a way to set-up a thunderbird account by using a script, i have been trying to to add the lines into the pref.js file but it keeps getting overwritten any help would be great thanks Adam (0 Replies)
Discussion started by: ab52
0 Replies

2. Solaris

Solaris User Accounts

Hi, Can you please tell me how to know the number of user account limit in solrise 5 version.Is there any cmd to see how many max user acc can be created. Thanks in advance (2 Replies)
Discussion started by: kkalyan
2 Replies

3. Solaris

Help with user accounts

Hi All, How to know all the shells a user has access. Thank you . (0 Replies)
Discussion started by: rama krishna
0 Replies

4. UNIX for Dummies Questions & Answers

Difference between : Locked User Account & Disabled User Accounts in Linux ?

Thanks AVKlinux (3 Replies)
Discussion started by: avklinux
3 Replies

5. UNIX for Dummies Questions & Answers

single user mode - user accounts passwords

hello ppl, someone must be able to help with this --> I have an old NCR tower 32 with an ADDS terminal running a unix version 020102 (Im not sure if thats correct but its unix for sure). I have no user names and no passwords and need to login to read a tape. Is there any way to do that? I hear... (3 Replies)
Discussion started by: orestis
3 Replies

6. Shell Programming and Scripting

Creating user accounts

Hi, I have written a program using shell scripting. When you run the file it will asks you to enter the user name, if the user exists it says " user exists " if not it will displays like " user doesnt exist" and then asks you like " do you want to add user with options Yes or No " if you say... (1 Reply)
Discussion started by: vishwaprasad
1 Replies

7. UNIX for Dummies Questions & Answers

Creating user accounts

Hey everyone I am new to the forums and to Unix. I am currently taking a class on Unix, our teacher posed the question to us How do u create a user account without using GUI or command? We are currently running Knoppix version of Unix and for the life of me I can't figure out how this is possible.... (0 Replies)
Discussion started by: Redditt90kg
0 Replies

8. UNIX for Dummies Questions & Answers

User Accounts

Hi, I was wondering if someone could tell me how to display a list of all existing user accounts on the system, not neccesarily looged in. Thanks in advance Stephen (3 Replies)
Discussion started by: sroberts82
3 Replies

9. UNIX for Dummies Questions & Answers

Help with user accounts

I have a root access to a UNIX system. I want to create another account with administrative permissions (create users, delete them, manage print and system configuration), how do I do that? I have a Solaris 9 (SunOS 5.9) installed. Please help. :o (3 Replies)
Discussion started by: neked
3 Replies
Login or Register to Ask a Question