Get premium membership and access revision papers, questions with answers as well as video lessons.

Comp 310: Unix Operating System Question Paper

Comp 310: Unix Operating System 

Course:Computer Science

Institution: Chuka University question papers

Exam Year:2012



CHUKA UNIVERSITY



COLLEGE

UNIVERSITY EXAMINATIONS

THIRD YEAR EXAMINATION FOR THE AWARD OF DEGREE OF
BACHELOR OF SCIENCE (COMPUTER SCIENCE)

COMP 310: UNIX AND C PROGRAMMING

STREAMS: B.SC. (COMP. SCI) Y3S2 TIME: 2 HOURS

DAY/DATE: TUESDAY 3/4/2012 8.30 A.M. - 10.30 A.M.
INSTRUCTIONS:

Answer QUESTION ONE and any other TWO questions.
This is a CLOSED BOOK exam. No reference materials are allowed in the exam room.
No mobile phone allowed in the exam room (make sure to switch it off and leave it with the invigilator if you carried one).
Write your answers legibly and use your time wisely.

Question One (Compulsory) [30 Marks]

Giving relevant examples, explain any TWO types of commands in UNIX. [3 marks]

What is a shell? [3 marks]

Explain what the following shell script code does. [3 marks]

#!/bin/sh
for file in *.txt
do
leftname= `basename $file .txt`
mv $file ${filename}.c
done

What is the significance of the line #!/bin/sh?

Explain the difference between the following set of commands:

cat list1.txt
more list1.txt [3 marks]
Explain the difference between the following set of commands: [3 marks]

Command 1: $ sed “s/myname/Goodluck/” inputfile>outputfile
Command 2: $ sed “2/myname/Goodluck/g” inputfile>outputfile

Write a perl program that prompts a user repeatedly to enter a number. When the user enters 0, the program should print the total. [6 marks]

How would you kill a process? [3 marks]

The command rmdirm_items failed. Explain three possible reasons. [3 marks]

Explain the order of execution of the following commands: [3 marks]

$ 1s unixstuff; cat animals.txt | sort | uniq


Question Two [20 Marks]

Write a perl program that populates an array named dayofweek from the string
SunMonTueWedThuFriSat, and then prints each day in uppercase. [8 marks]

Identify any FOUR syntactical errors in the shell program shown below: [4 marks]

#!/bin/sh
prunning=yes
echo “Enter value of index [value 1 – 19]:”
read index
while $prunning = yes ; do
$index + 1
sleep $index
if [ $index => 20 1 ] ; then
break
done # endwhile
echo “Job done”

Write a shell script that prompts for a string and then checks whether it has at least
10 characters. [5 marks]

What are links and symbolic links in UNIX file system? [3 marks]






Question Three [20 Marks]

Explain the purpose of each of the following commands, and how to use them, giving examples: [12 marks]
(i) 1s -1d
(ii) ssh
(iii)shutdown
(iv) scp
(v) chmod
(vi) ping

What is the advantage of executing a process in background? [3 marks]

Write a perl program that prompts a user to input a string and a number, and prints the string that many times, with each string on a separate line. [5 marks]


Question Four [20 Marks]

Assuming that a file’s current permissions are rw-r-xr--, specify the chmod expression required to change them to: [9 marks]

(i) rwxrwxrwx
(ii) rwxrw-r--
(iii) ---r --r--
(iv) ---------

Using only relative permissions:

Explain fork( ) system call. [4 marks]

Write a shell program script logic that allows only fred and cate to execute a program, and only from the terminals tty08 and tty09. [7 marks]


Question Five [20 Marks]

Describe the contents of a directory, explaining the mechanism by which its entries are updated by cp, mv, and rm commands. [6 marks]

Explain the difference between the commands cd *backup and cd~/backup. Is it possible for both commands to work? [4 marks]

Explain the three different directory access permissions. Given some administrative tasks, explain how you would change these Access Permissions. Use examples to illustrate your answer. [10 marks]
---------------------------------------------------------------------------------------------------------------------






More Question Papers


Popular Exams



Return to Question Papers