Assignment1 CSCI322
Assignment1 CSCI322
Assignment 1
Published on 22 July 2024
Due: Saturday 24 August 2024, 11:30 pm
Total Marks: 10 marks
Objective:
1. Understand user management and UNIX/LINUX programming using scripting languages.
2. Demonstrate the ability to manage and maintain the user account and log.
It is recommended to solve the problems before attending the laboratory classes to efficiently use supervised
laboratory time.
A submission marked by Moodle as Late is treated as a late submission no matter how many seconds it is
late.
A submission of compressed files (zipped, gzipped, rared, tared, 7-zipped, lhzed, … etc) is not allowed. The
compressed files will not be evaluated.
It is expected that all tasks included in Assignment 1 will be solved individually without any cooperation
from the other students. If you have any doubts, questions, etc. please consult your lecturer or tutor during
lab classes or office hours. Plagiarism will result in a FAIL grade being recorded for the assessment task.
Task 1: User management (6 marks)
A company has set up a new branch and transferred employee accounts to the new branch’s server.
Your task is to write a Bash script to create user accounts for all TECHNICs and SUPPORTs. The supplied
file employees.txt is a text file that contains an employee name and the type delimited by a comma per line.
There are two types of employees: TECHNIC employees and SUPPORT employees. Technic employees are
added to the technic group and support employees are to the support group.
1. Write a Bash script createUsers.sh to do the following.
A user ID is formed by the first letter of the first name, a dot, and the last name of an employee. For
example: The user ID for an employee “Andrew K Smith” is “a.smith”.
If a user ID already exists, then append 2 digits to the end of the user ID. For example: The user ID
for an employee “Andrew R Smith” was “a.smith”. But this user ID already exists. In this
case, the user ID is changed to “a.smith01”.
A random password for a user is a string of 8 characters’ length. It contains alphabet letters and
digits.
You may combine this step with the next step to create a user account with a random password in
one script.
Only creating a user in the next step without a random password will lose marks in this part.
(2 marks)
c. Create an account by using a user ID with its random password created in the previous step
and add the user to its group.
All user accounts are created with a random password, and a home directory with the same
name as their user ID in the /home directory; all accounts use the Bash shell program.
(1 mark)
d. Write messages to syslog for all the above events (new group, new user creation).
Note that while the current need is to handle a limited number of usernames from the given user file,
your script should be able to handle an arbitrary number of employees.
(1 mark)
2. Write a Bash script, called reportTechnics.sh, to report the members of the technic group to the
file /tmp/technics.txt.
Write a Bash script, called reportSupports.sh, to report the members of the support group to the
file /tmp/supports.txt.
(0.5 marks)
3. Create a crontab entry to call the reportTechnics.sh and reportSupports.sh script at
08:00AM and 11:00PM on every weekday.
(1 mark)
Take a screenshot of all processing results for each question and put them in the report file
Task1_<your-name>_<your-student-id>.pdf.
Deliverables
a) Write a one-line commands to find how many POST events, in which the host’s domain is “unl.edu”
appear in the log? Show the command you use to determine the number.
(1 mark)
b) Write a one-line commands to find the GET events that happened on “01/Aug/1995” for the
/history/mercury/mercury-spacecraft.txt file. The output should list the fully qualified
hostname and its time of access. (Don’t worry about removing any square brackets.)
(1 mark)
c) Write a one-line commands to print all the Expendable Launch Vehicle (ELV) names listed
in the log. The ELV names are all listed in capital letters under the /elv directory. The output names
appear in the format of one name per line, in the alphabetical order without duplicates.
ATLAS_CENTAUR
DELTA
DOCS
…
Save your output in a text file called elv.txt.
(2 marks)
Take a screenshot of Bash shell scripts with processing results for each question and put them to the report
Task2_<your-name>_<your-student-id>.pdf. You must give explanations and observations.
If you have only screenshots, you will get lower marks.
Deliverables
Save your report (includes screenshots of Bash shell script and the processing results, explanations, and
observations for each question) to a file Task2_<your-name>_<your-student-id>.pdf. Submit
it to Moodle before the deadline.
Submission
Note that you have only one submission. So, make absolutely sure that you submit the correct files with the
correct contents and correct types. No other submission is possible!
End of specification