Test2 - Second test for unix PDF

Title Test2 - Second test for unix
Author Jazib Azam
Course Unix Essentials for System Administrators
Institution Royal Melbourne Institute of Technology
Pages 9
File Size 693.9 KB
File Type PDF
Total Downloads 5
Total Views 154

Summary

Second test for unix...


Description

COSC2506 UNIX Essentials for System Administrators Semester 1 2020

Practical Test 2 (20 % -20 points) User Management Writing Shell Scripts

Student ID

___________________________

Student Name ___________________________ Date

___________________________

Preparation Before starting this lab, you should review Topic 6 – Managing Users and Groups & Topic 7 – Scripting.

➢ Remove the password from this file. ➢ Rename this file yourname.docx. ➢ Power on the virtual machine (Solaris 11). ➢ Log in as student.

➢ Access the Command Line (Terminal)

Task 1 - User Management (CLI) (10 x 0.5 = 5 points) Enter the commands to perform each of the following tasks. Note: Use # (comment) before a question number and on the following line type the command.

1. Create a new user (User Name: mia, UID: the last three digits of your student number) using CLI. 2. Change mia’s password (mia2020) 3. Create a new group (test2, GID 110). 4. Add mia to this group. 5. Assign a root role to mia. 6. Create a file named miafile. 7. Change the ownership of miafile to mia. 8. Change the group for miafile to test2. 9. Display mia's user account from the /etc/passwd file. 10. Display the group information about the test2 group.

Copy your Task 1 answers from the terminal here: 1. Create a new user (User Name: mia, UID: the last three digits of your student number) using CLI. useradd -u 305 mia 1. Change mia’s password. (mia2020) passwd mia (type mia2020) 2. Create a new group (test2, GID 110). groupadd -g 110 test2 3. Add mia to this group. usermod -g test2 mia (or -G to add a secondary group) 4. Assign a root role to mia. usermod -R root mia 5. Create a file named miafile. touch miafile 6. Change the ownership of miafile to mia. chown mia miafile 7. Change the group for miafile to test2. chgrp test2 miafile 8. Display mia's user account from the /etc/passwd file. cat /etc/passwd or grep mia /etc/passwd 9. Display the group information about the test2 group. cat /etc/group or grep test2 /etc/group

Task 2 – Writing Shell Scripts (15 points) ➢ You have to write four scripts . TWO scripts are worth 3 points and TWO scripts are worth 4 points. Script 1 (3 points)

Script 2 (3 points)

Script 3 (4 points)

Script 4 (4 points)

➢ Copy the SCRIPTS/CODES and the OUTPUTS to this file (in the space provided). Example: SCRIPT CODE #! /bin/sh echo "The name of the script file is $0." echo "The shell script was called with $# arguments." OUTPUT student@solaris:~/test2_db$ sh example.sh Practical Test 2 The name of the script file is example.sh. The shell script was called with 3 arguments.

➢ If your script is not working, submit the code. You will be given reduced points – depending on the type of error. Correct script with the output provided: 3 points script – 3 points 4 points script – 4 points Correct script without output provided: 3 points script – 2.5 points 4 points script – 3.5 points Incorrect script: 3 points script – Maximum 2 points. Further points deduction will apply for multiple errors. 4 points script – Maximum 3 points. Points deduction will apply for multiple errors.

Preparation for Task 2 (1 point) ➢ Create a folder called yourname_test2 and save all your scripts into that folder. ➢ Create a file named tests.

➢ Change permissions for this file to 755. ➢ Create a directory named unix. Script 1 (3 points) Write a script (script1.sh) that compares two strings (use read command) and displays the longer string. If they are the same length display the first string. After that the script will display the name of user who run it, and the day when it was run. The output should look like the following:

Note: The day of the week will be different.

Script 2 (3 points) Write a script (script2.sh) that would first check if directory "user_directory" (user input – argument 1) exists. • If the directory exists rename it to another directory with the same name and the extension .dircopy (user_directory.dircopy). • If the directory does not exist print an error message and create it. The output should look like the following:

Script 3 (4 points) Create a script (script3.sh) that will allow student to read in the first name (NAME) and the number of hours (NO_H) he/she spent studying for this course. It will then figure out the output message. No_H Message No_H>=20

Hi NAME. Your GPA will stay high.

15...


Similar Free PDFs