In: Computer Science
Prof. Orlando Karam maintains an Ubuntu Linux server for his class. Every semester he needs to create an account for each student. It takes a lot of time to create these accounts one by one interactively. So he decides to automate the process by writing a script. You are Orlando’s TA and volunteered to complete the task. Please propose a solution and write a script (either Bash or Perl) to implement your solution. Basic requirements: The script reads from a CSV file for student information (exported from Excel). The file is made up of the lines like this: Jack,Zheng,jzheng3 //[first name],[last name],[campus email id] Mark,Cuban,mcuban2 … Please make up your own CSV file (with at least 5 students/lines) for testing purpose. Every student is assigned a common initial password (you will determine the password). Students are required to change their passwords at first login. All student accounts should be assigned to a “student” group. This group already exists in the system (you need to create this group first for testing purpose). Make some other assumptions if not specifically required. Reminder: you will and should do some research on how to read and parse CSV files, and how to process passwords programmatically. Execute your script and take two screen shots: a. The “passwd” file content, with the new accounts clearly shown. b. The “shadow” file content, with the new accounts clearly shown. 2. Login with one of the new student account and show that you have successfully logged in using the newly created account. Take a screen shot showing the user id in the terminal. 3. Compile one PDF document with the script, the CSV file content, and all three screen shots, clearly labeled for each part.
student.csv file
john paul jpaul12
mark andre mandre23
chris vincent cvincent34
mary renolds mrenolds45
tim cook tcook56
Bash Script :
#!/bin/bash
if [ $# -eq 0 ]
then
echo "Usage : new_student.sh student_file.csv"
exit 1
fi
student_file=$1
for line in `cat $student_file`
do
fname=`echo $line | cut -d',' -f1`
lname=`echo $line | cut -d',' -f2`
id=`echo $line | cut -d',' -f3`
sudo adduser $id --gecos "$fname $lname"
--disabled-password
echo "$id:password" | sudo chpasswd #default password
as "password"
sudo usermod -a -G student $id
done
Outputs :
Script Execution

Contents of passwd file

Contents of shadow file

logging in to a new user and changing the password
