Вы находитесь на странице: 1из 5

Bahria University Islamabad

Department of Computer Science


Mid Term Exam, Operating System Lab (CSL320), Spring 2019 (BSIT-5A)
Instructor: Syed Saqlain Hassan
Total Points 35 Weightage of Paper 20% Friday, March 29, 2019

Name: Enrollment #:

Instructions:
 This exam is to be completed by each student individually, with no assistance from other
students.
 You have 2 hours (120 minutes) to complete this exam.
 The Exam is closed book & notes. You may not use any paper or internet resources. You
may not use any computing devices, including calculators, cell phones, iPads etc.
 All questions are compulsory.
 There are total three questions. For Question #1 write the correct option in corresponding
box. Deleting/Cutting will lead to Zero for that part.
 Use blue, black or blue-black ink only. Do NOT use lead pencil especially.
 Unless otherwise indicated, your code will be graded on proper behavior/output, not on
style.
 On code-writing problems, you are required to write a complete program, like echo Enter
your name, (function, etc.) specified in the problem statement.
 Do not abbreviate code, such as writing ditto marks ("") or dot-dot-dot marks (...).
 Follow the Bahria University Honor Code on this exam and correct/report anyone who
does not do so.
Question#1
[Max. Points 25]
1. Suppose x =10, then what will be the value of x$x$?
a) undefined
b) erroneous
c) 100
d) x10$
2. Given x=10 then, x$x$ == $x$x, The given statement is
a) True
b) False
3. Where is the exit status of a command stored?
a) $0
b) $>
c) $1
d) $?
4. Which of the following is false?
a) $# stores the number of arguments specified
b) read command is used for making scripts interactive
c) $* stores the number of arguments specified
d) && and || are logical operators
5. Every time shift command is used, the leftmost variable is lost.
a) True
b) False
6. Which one of the following is used for looping with a list?
a) while
b) until
c) case
d) for
7. Which command is used by the shell for manipulating positional parameters?
a) set
b) cut
c) case
d) paste
8. The ___ option in case statement matches any option not matched by the previous options.
a) ^
b) $
c) *
d) //
9. Which option is used for checking if the file exists or not?
a) -e
b) -a
c) -n
d) -f
10. Which of the following operators is used with test for comparison of numeric values?
a) -eq
b) -ne
c) -gg
d) –eq and -ne
11. When we use &&, the second command is executed only when first succeeds.
a) True
b) False
12. When we use ||, both the commands are executed.
a) True
b) False
13. What are positional parameters?
a) special variables for assigning arguments from the command line
b) pattern matching parameters
c) special variables for reading user input
d) special variables and patterns
14. Which command is used for acquiring superuser status?
a) pu
b) su
c) admn
d) super
15. A file named abd.txt has the following set of permissions rwxrwxrwx. All the three operations can
be performed on the file by file owner, group owner and others.
a) True
b) False
16. A file has permissions as rwx r– —. A user other than the owner cannot edit the file.
a) True
b) False
17. chmod command can be used in ____ ways.
a) 3
b) 2
c) 5
d) 0
18. Which of the following symbol is used with chmod to assign permission to a file?
a) –
b) /
c) +
d) *
19. To assign execute permission to the user (owner) for a file named MidExam.txt, which of the
following command will be used?
a) chmod u+r MidExam.txt
b) chmod u+w MidExam.txt
c) chmod u-x MidExam.txt
d) chmod u+x MidExam.txt
20. What does the following command do?
$ chmod ugo +w MidExam.txt
a) assign write permission to users, group and others
b) assign write permission to the user (owner) only
c) assign write permission to group and others
d) command not executable
21. To remove write permission from group and others, which one of the following commands will be
used?
a) chmod go+w MidExam
b) chmod go-w MidExam
c) chmod ug-w MidExam
d) chmod a-w MidExam
22. What are the permission of MidExam after executing this command?
$ chmod 561 MidExam
a) r-xrw---x
b) rw-rw-rw
c) r–r–r–
d) r–r—-
23. A file named MidExam should be readable, writable and executable only by the user(owner).
Which one of the following set of command will be used?
a) chmod 700 MidExam
b) chmod 000 MidExam
c) chmod 477 MidExam
d) chmod 777 MidExam
24. What does the following command do?
$ vi MidExam
a) open file named MidExam
b) edit file named MidExam
c) delete a file named MidExam
d) open file if it exists else creates a new file
25. The name of the script is stored in which special parameter?
a) $1
b) $0
c) $#
d) $*
Question#2
[Max. Points 05]
Create a script MidTermQ2.sh and Write a shell script that lists all the directory files in a directory. The
shell script should read the directory name as an argument or you can also make it interactive and then it
will return the list of directories in the given directory. Write all necessary steps for running and executing
MidTermQ2.sh.
(write your code here)
Question#3
[Max. Points 05]
Write a menu driven script that should perform the following tasks. Your Script should be interactive &
should handle invalid inputs.

Menu-Item Purpose Action for Menu-Item


Date To see current date time On Selecting/Pressing “1” Date should be displayed.
On Selecting/Pressing “2” Script should create a directory
Create To Create Directory
and ask for the name of directory.
On Selecting/Pressing “3” Script should create a directory
and ask for the name of directory.First ask user name of
directory where all files are present, if no name of
directory given assumes current directory, then show all
Delete To delete Directory
files only of that directory, then ask the confirmation to
user whether he/she wants to delete Directory, if answer is
yes then delete the Directory , report errors if any while
deleting directory to user.
On Selecting/Pressing “4” Script should create a directory
Exit To Exit this shell script and ask for the name of directory. Exit/Stops the menu
driven program i.e. this script.

(write your code here)

Вам также может понравиться