- Mar 8, 2005
- 8,805
- 65
- 91
I have a ubuntu server that needs a few hundred accounts created on it. All of these accounts are in this format
student[room number]u[user number] (example student123u1 or student225u30)
50 accounts will be made per room and the passwords will be identical for the user name. These accounts are going to be used for a semester then removed at the end of the semester and replaced.
I have written the following script
roomlist.txt is a text file with the following format
Similarly I have a script that replaces the inner do loop with userdel -r $user to delete each user as so:
Any suggestions on a better way to write these scripts or stream line them?
student[room number]u[user number] (example student123u1 or student225u30)
50 accounts will be made per room and the passwords will be identical for the user name. These accounts are going to be used for a semester then removed at the end of the semester and replaced.
I have written the following script
roomlist.txt is a text file with the following format
student123u
student563u
student121u
etc
#!/bin/bash
for y in `more roomlist.txt`
do
for x in {1..50}
do
user=$y$x
password=`mkpasswd $user`
useradd $user -m -p $password
echo Account created for User: $user
done
done
Similarly I have a script that replaces the inner do loop with userdel -r $user to delete each user as so:
#!/bin/bash
for y in `more roomlist.txt`
do
for x in {1..50}
do
user=$y$x
userdel -r $user
echo Account deleted for User: $user
done
done
Any suggestions on a better way to write these scripts or stream line them?
