OPERATING SYSTEMS UCCD 2103
OCT 2019
ASSIGNMENT REPORT Part B
V1.2
No.
Student ID
Name
Programme (CN/CS/CT/IA)
1
2
3
1
Assignment Guideline:
This assignment is a group assessment. Each group (max. 3 students per group) has to practice the following and submit the hardcopy reports. There is no restriction of forming a group out of your tutorial group. Maximum marks for this assignment (Part B) is 100. It requires you to use the Linux OS. Running a virtualized Linux (Virtualbox or VMWare Player) is acceptable. You can use either 32-bit or 64-bit Linux, depending on your host OS if you use virtualization. For example, if your computer runs on Windows 7 32-bit, then you have to use Linux 32-bit on your virtual machine. To limit uncertainties and possible issues you might run into, you are recommended (but not limited) to use Fedora or CentOS for this assignment. Make sure you allocate at least 50GB for your Linux partition. The username of your Linux system must be set to your first name. For example, the username of my system is cheesiang. Successful installation of Linux OS will be awarded 25 marks. Your report shall contain all group members names and IDs, and your group leaders email address. Also, write down the specification of the system that you use to perform this assignment at the last page of your report. Your report should provide the screenshots of the terminal to support all your answers. If the screenshot size is too big and resulting to a very small font size in your printout, you may resize your desktop resolution to 800600 before taking the screenshot. If the screenshot is still too large (or the font is too small), you may crop it; as long as you can proof the originality of your work, by showing the username in your terminal. For example, for command lines-based question, you should not crop out your username as it is used to identify your groups work. Any group reports that have the same screenshots or usernames will be counted as plagiarism and be given 0 marks. The report and source codes shall be printed in black and white colour, double sided, and without comb binding to minimize cost. Please compress the softcopy of your report and source codes and upload it to the WBLE. Use the following naming format: yourname_tutorialgroup. Please cite all the references you use. The compressed file for WBLE submission shall have the following:
Folder: Part B source codes o Q1a.sh
o multi.sh
o count_logfile.sh
PDF file: Report.pdf
Text file: Group_members.txt (Group members list)
Only the group leader needs to upload the soft copy to WBLE. Please cite all the references you use. due date is 22nd of November 2019, 10AM. Please submit the hardcopy to Mr. Jason Lims office at NG-001.
V1.2
2
Part B: Linux Administration
1. Basic Bash
a. A shell script is a sequence of shell commands written in an executable script file.
Executing this file instructs the shell to execute all commands in the order of their appearance in the script file. There exist several shell scripting tutorials available on the web, e.g. search by entering the keywords Linux shell script tutorials. Go through one of these tutorials and then write a shell script that displays the following system parameters:
i. Your users name
ii. The kernel version of your Linux OS
iii. The number of cores in your processor
iv. The current directory of the terminal
v. Date of the system
vi. The local IP address of your system
vii. The total main memory (RAM) and free memory the system has
viii. The uptime elapsed in your system at the time you run the script
ix. All secondary storage in your system
x. Completely Fair Schedulers period (Hint: it is stored in
/proc/sys/kernel/sched_latency_ns)
You need to include the script and also screenshot of the results after the script is executed in your hardcopy report. Please include the shell script codes into softcopy as well. (10 marks)
b. Write a simple bash shell script that performs deduction multiplication of two integer inputs via two input arguments. E.g. when your run the script: ./multi.sh 2 8 it will output 16. Note: you must strictly use the input arguments. Do not prompt the user to key in the input one by one during runtime.
(5 marks)
c. ps is a command that displays information about all processes currently running in your system. Read man page of ps command (type man ps). E.g. the following commands: (1) ps ef | more and (2) ps aux | more will result in displaying a long list of processes with some parameters associated with them.
i. Write the bash ps command to retrieve the following information: For each task, find out who owns it, what code (the task name) it is running, and how much CPU/memory it has used. Then, output this information into a file called processes.log. (4 marks)
ii. Write another bash command to read processes.log and filter it so that it only shows the processes started by you (as in your username). Finally, output this information into a file called user.log. (6 marks)
Write down the commands and screenshots of outputs in your report.
V1.2
3
2. Linux Access Control / File Permission
Download pi and text.txt executable file from WBLE.
a. Execute the pi. You will notice it failed to execute. List the command to give
execute permission of the file to your current user ID. b. Using root credential, create the following:
(3 marks)
(3 marks)
i. Group ID group2 that have users ID user2 and user3 under it
ii. Group ID group3 that has username ID user4 under it.
(3 marks) c. Assume that the text.txt is owned by user2. List the complete command so that the text.txt can be read and write by user2, can be only read by user3, but
V1.2
cannot be accessed by anyone in group3. (6 marks) Hint: Learn how to use Linux Access Control to control file permission.
3. File processing using gawk loop and variables
The directory netstat contains daily internet usage log files for different months of the year. The log files are arranged into folders, one for each month. Each log file contains the following fields separated by semi-colon (;).
Counting number of log files using gawk
Complete the bash shell script count_logfile.sh that counts the number of log files stored in each month . Gawk is optional. It also shows the total number of log files stored in the netstat directory. The shell script receives the path of the netstat directory. A sample output is given below. Your shell script should have the same output.
Your script should inform the user how to use count_logfile.sh if they do not supply the correct number of arguments to the shell script. Show the screenshot of your script in the report. Include the count_logfile.sh in the softcopy submission.
(35 marks)
References:
Linux Shell Scripting Tutorial v1.05r3: A Beginners handbook. 2018. [ONLINE] http://www.freeos.com/guides/lsst/ . [Accessed 01 November 2018].
How to use POSIX semaphores in C language2018. [ONLINE] https://www.geeksforgeeks.org/use-posix-semaphores-c/. [Accessed 01 November 2018].
Name
Department ID
Accessed website
Usage (KB)
Time
using gawk
4
Reviews
There are no reviews yet.