02-15-2004
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!!!
9 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
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
2. UNIX for Dummies Questions & Answers
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
3. UNIX for Dummies Questions & Answers
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
4. Shell Programming and Scripting
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
5. UNIX for Dummies Questions & Answers
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. UNIX for Dummies Questions & Answers
Thanks
AVKlinux (3 Replies)
Discussion started by: avklinux
3 Replies
7. Solaris
Hi All,
How to know all the shells a user has access.
Thank you . (0 Replies)
Discussion started by: rama krishna
0 Replies
8. Solaris
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
9. OS X (Apple)
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
LEARN ABOUT CENTOS
lnewusers
lnewusers(1) General Commands Manual lnewusers(1)
NAME
lnewusers - Create new user accounts
SYNOPSIS
lnewusers [OPTION]...
DESCRIPTION
Creates new user accounts using data read from standard input.
The input data consists of lines, each line has 7 colon-separated fields:
User name
Plaintext password
User ID
lnewusers refuses to create users with user ID 0 (the root user ID).
Group If this field is a valid group ID, it is interpreted as a group ID, otherwise as a group name. If the field is empty, a group name
equal to user name is used.
If the specified group does not exist, it is automatically created. If the group is specified with a group ID, the created group
has group name equal to the user name.
GECOS The GECOS field is traditionally used to store user's real name and other information.
Home directory
If this field is empty, a default specified by libuser configuration, or /home/username if libuser configuration does not specify a
default, is used.
Login shell
If this field is empty, a default specified by libuser configuration is used.
Errors in user specifications are reported and processing continues on the next line.
OPTIONS
-f, --file=file
Read account data from file instead of standard input.
-i, --interactive
Ask all questions when connecting to the user database, even if default answers are set up in libuser configuration.
-M, --nocreatehome
Don't create home directories.
-n, --nocreatemail
Don't create mail spool files.
EXIT STATUS
The exit status is 0 on success, nonzero on fatal error. Errors in user specifications are not reflected in the exit status.
libuser Jul 13 2008 lnewusers(1)