Question

In: Computer Science

Prof. Orlando Karam maintains an Ubuntu Linux server for his class. Every semester he needs to...

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.

Solutions

Expert Solution

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


Related Solutions

Describe AppArmor and its functions with Ubuntu Server 18.04 and Linux  
Describe AppArmor and its functions with Ubuntu Server 18.04 and Linux  
Prof. X has two brilliant students Y and Z in his class. He introduces the concept...
Prof. X has two brilliant students Y and Z in his class. He introduces the concept of vector spaces, bases and dimension in his 5th session. As an exercise, he gives a vector space V of dimension n and asks Y and Z to find a basis. Y produces a set S with n elements. But Z being lazy, takes the set S, removes a vector and adds a new vector to it creating a new set T. Prof. X...
QUESTION 7 Michael surveys children in the special needs class at his church. He wants to...
QUESTION 7 Michael surveys children in the special needs class at his church. He wants to know how supportive relationships can influence autistic children's social development. What is the sample? autistic children the special needs class at Michael's church supportive relationships social development QUESTION 8 When conducting a statistical test, a high p-value indicates a low level of practical significance. a high level of practical significance. a low level of statistical significance. a high level of statistical significance. QUESTION 9...
During the semester, we have started every class with discussing a current event and analyzing it...
During the semester, we have started every class with discussing a current event and analyzing it from a legal point of view. Finally, we discussed the business implications of such legal assessment and the steps a business-person could take to protect against the risks caused by these events. For instance, during the Chapter on contracts, we discussed the implications of the Coronavirus. First, we discussed how the World Health Organization categorized it then as an epidemic. Then we discussed how...
Bob just had his annual physical and agreed with his doctor that he needs to lose...
Bob just had his annual physical and agreed with his doctor that he needs to lose weight and eat a healthier diet. On the way home, he stopped at the drive-through and got a double bacon cheeseburger and deep-fried cheese curds. Bob is experiencing cognitive dissonance, what can he do?
Professor realizes that he hates his class and has decided to give each of his students...
Professor realizes that he hates his class and has decided to give each of his students a 20-point decrease in all their grades for no reason. Help him write the C++ code that will allow him to do this. Consider the code on the next page. It creates an array of 10 structs called students which contains their name and their grade. It is nearly complete. Your task is the following: Complete the user-defined function called subtractTwenty. You will need...
Jake routinely directly holds his own stocks. He updates the stocks in his portfolio every week,...
Jake routinely directly holds his own stocks. He updates the stocks in his portfolio every week, trying to pick the stocks that will perform the best over the next week. Jake is managing his assets using ________. an active investing strategy a passive investing a mutual fund a bank Suppose that you own stock in a company that sells flour. If you wanted to diversify to protect your portfolio against the risk that severe flooding might cause crop failure, leading...
Josh needs $320 to pay off his cell phone. He can use his credit card, but...
Josh needs $320 to pay off his cell phone. He can use his credit card, but the $320 payment will put him at his card limit. His other option is to take out a payday loan. His credit card has an annual rate of 16.8% compounded daily. The payday loan charges a daily rate of 0.75%. Calculate the cost of both options if he will pay both off when he receives his next pay cheque in 3 weeks.
Mr. Rashid plans to purchase the electronics itemsbased on his budget. So he needs a...
Mr. Rashid plans to purchase the electronics items based on his budget. So he needs a purchase planner which will help to calculate the price of electronics items, he can purchase based on the available amount. If Mr. Rashid enters his budget amount and chooses the numbers of electronic items from the list of available electronic items, the purchase planner will calculate the cost of electronics items based on the number of items selected, the total cost of all the...
Tony wants of open his own business. He needs a mortgage of $400,000 to build a...
Tony wants of open his own business. He needs a mortgage of $400,000 to build a plant to get his business started. After doing some research, he has decided that the best rate is 4.5% with semi-annual compounding. The mortgage is amortized for 25 years, but the initial contract is for 10 years with constant total payments. 1) What is the semi-annual payment? 2) Make a semi-annual mortgage repayment scheme showing for each time period the principal, principal repayment, interest,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT