0% found this document useful (0 votes)
201 views

Lab 3 - File Management - v2

This document provides instructions for a lab assignment on file management in Linux. It asks students to: 1) Create directories and files using bash scripts and draw the resulting file structure. 2) Write an interactive bash script to display and count files of a given extension. 3) Create additional directories and files to match a given structure, and fill out a table with the access permissions. 4) Write a bash script to change the permissions of some directories and files based on given specifications, and update the permissions table.

Uploaded by

Vatsala Raj
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
201 views

Lab 3 - File Management - v2

This document provides instructions for a lab assignment on file management in Linux. It asks students to: 1) Create directories and files using bash scripts and draw the resulting file structure. 2) Write an interactive bash script to display and count files of a given extension. 3) Create additional directories and files to match a given structure, and fill out a table with the access permissions. 4) Write a bash script to change the permissions of some directories and files based on given specifications, and update the permissions table.

Uploaded by

Vatsala Raj
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Lab 3 (FILE MANAGEMENT) |1

SCSR2043 OPERATING SYSTEMS


[20 Marks]

Name : Marks
Student :
ID
Section :

Instruction: Please answer all the following questions.

1. Type the following commands using a text editor and save it as a yourname.sh
(Example: ahmad.sh).

echo “Hello world” > helloworld.jar


mkdir cars; mkdir dates; mkdir fruits drinks
cd cars; echo “Honda Accord” > accord.c
cp accord.c civic.c; echo proton > proton.c; cd ../dates;
date > dateoftheday
cat dateoftheday > appointment
cd ../fruits; echo apple > apple.txt; cat apple.txt >
orange.txt
cd drinks; cp ../cars/*.* .; cp ../fruits/*.* .;
cp ../*.jar .

a) Execute the script and draw a tree structure that contains created directories and
files. The parent node of the directory begin with $HOME directory.
[4 marks]

$HOME

Print screen the script that you type;

Then draw the tree


Lab 3 (FILE MANAGEMENT) |2

b) Write an interactive bash script that will read a type of file extension, display all
those files, and count the number of files. To validate your script, display c
program files, and enter “c” as the input to the bash script. [4 marks]

Print screen the bash script you type and run

2. The following Figure 1 illustrates a tree structure of some directories and files.

$HOM

subject faculti books


s es
Directory - Linux_operating_systems
- operating_systems - Best_of_software_engineering
Text Files - software_engineering
- data_communication

FCS FBE

- dean - Project_Manager
- deputy_dean

Figure 1
Lab 3 (FILE MANAGEMENT) |3

a) Write a bash script (called myname2a.sh) that will produce directories and
files as in Figure 1. Each text files contain its filename without the underscore
character. For example: text file Project_Manager contains Project
Manager). [4 marks]

Print screen the bash script you type and run

b) Complete the following table by writing the access control of directories or files
that were produced. Given is the access control for directory called book.
[2 marks]

Directory/File Access Control


books drwxrwxr-x
subjects
Best_of_software_engineering
FCS
project_manager
Lab 3 (FILE MANAGEMENT) |4

c) Write another bash script (called myname2c.sh) that will change the access
control of the directories and files based on the following information:
[4 marks]

Users
Directory/File
Owner Group Public
subjects ! ! ! ! x x ! x x
Best_of_software_engineering ! x ! x ! x x x x
FCS ! ! x x x x ! ! !
project_manager x x x x ! ! x x !

Print screen the bash script you type and run


Lab 3 (FILE MANAGEMENT) |5

d) Complete the following table by writing the access control for each directory or
file after executing the bash script in question 2(c)). [2 marks]

Directory/File Access Control


subjects
Best_of_software_engineering
FCS
project_manager

End of Lab 3

*** All the Best for Final Exam ***

You might also like