Tlcm 323: Introduction To Unix/Linux Os Question Paper

Tlcm 323: Introduction To Unix/Linux Os 

Course:Bachelor Of Telecommunication And Information Engineering ()

Institution: Kabarak University question papers

Exam Year:2011




KABARAK UNIVERSITY
UNIVERSITY EXAMINATIONS
2011/2012 ACADEMIC YEAR
FOR THE DEGREE OF BACHELOR OF SCIENCE IN
TELECOMMUNICATION
TLCM 323: INTRODUCTION TO UNIX/LINUX OS
DAY: FRIDAY DATE: 23/03/2012
TIME: 9.00 – 12.00 P.M. STREAM: Y3S2

INSTRUCTIONS:
Section A is COMPULSORY (40mks). Attempt ANY THREE questions from
Section B (20mks) each.
SECTION A – (40mks)

Question 1
(a) Which commands create a tar containing files “g”, “b”, and “d”? (1mk)
a. tar –cvf file.tar g b d
b. tar –tvf file.tar g b d
c. tar –xvf file.tar g b d
d. none
(b) Which are the four navigation keys in “vi”? (1mk)
a. h-j-k-l
b. l-u-d-r
c. h-u-n-j
d. a-q-s-d
(c) Indicate which command(s) are syntactically correct. (1mk)
a. ls -ld a* b*
b. ls -l-d a* b*
c. ls -l -d a* b*
d. ls -l a* -d b*
(d) Consider the following commands which have been entered one after the other, and
indicate which output is generated by the last command. (1mk)
$ mkdir a
$ cd a
$ ps > a
$ ls > b
$ cat b a
(a) Error !
(b) PID TTY TIME CMD
29362 pts/3 0:00 -ksh
92598 pts/3 0:00 ps
a
b
(c) a
b
PID TTY TIME CMD
29362 pts/3 0:00 -ksh
2
92598 pts/3 0:00 ps
(d) a
PID TTY TIME CMD
29362 pts/3 0:00 -ksh
92598 pts/3 0:00 ps
(e) PID TTY TIME CMD
29362 pts/3 0:00 -ksh
92598 pts/3 0:00 ps
a
(e) Which of the following will display the string "oops" when the command mkdir
/tmp/bar fails? (1mk)
a. mkdir /tmp/bar && echo "oops"
b. mkdir /tmp/bar || echo "oops"
c. mkdir /tmp/bar ; echo "oops"
d. mkdir /tmp/bar | echo "oops"
(f) How can you append the output of a command to a file? (1mk)
a. Command <> file
b. Command << file
c. Command >> file
d. Command > file
e. Command < file
(g) Look at the result below and answer the following three questions.
-rw-r--r-- 2 tb00029 staff 74 Dec 26 16:50 a
-rw-r--r-- 1 tb00029 staff 0 Dec 26 16:50 b
drwxr-xr-x 2 tb00029 staff 512 Dec 26 16:50 c
-rw-r--r-- 2 tb00029 staff 74 Dec 26 16:50 d
lrwxrwxrwx 1 tb00029 staff 1 Dec 26 16:51 e --> d
I. Which command may have produced these lines? (1mk)
(a) ls –l
(b) ls –al
(c) ls –pl
(d) ls –pe
II. In the same situation, which command(s) may have created file “b”? (1mk)
(a) >b
(b) cat > b
(c) cat | b
(d) touch b
III. In the same situation, how was file “e” created? (1mk)
(a) >e
(b) touch e
(c) cat > e
(d) cp e d
(e) ln e d
(f) ln -s e d
(h) Which of the following command(s) can be used to change the scheduling priority of a
running process? (1mk)
a. kill
b. ps
c. renice
d. top
(i) To copy all files starting with ‘a’ into the subdirectory ‘c’, I should enter the following
command: (1mk)
a. cp a* c
b. cp a? c/
c. cp a[*] c
d. mv a? /c/a
e. cp a* /c/a
f. mv a* c/
(j) Which command(s) was entered to change the file permissions of ‘a’ from the first to the
second form below? (1mk)
-rw-r--r-- 2 tb00029 staff 74 Dec 26 16:50 a
......
3
-rwxrw---x 2 tb00029 staff 74 Dec 26 16:50 a
(a) chmod 761 a
(b) chmod 167
(c) chmod +124 a
(d) chmod ou+x,g+w,o-r a
(e) chmod u+x a; chmod
o+x;
(f) none of the above.
(g) This is impossible with a
single command. One
needs a command to
remove permissions and
one to add permissions
back.
(k) Which of the following will send the standard error of mkdir /tmp/foo to /dev/null?
(1mk)
a. mkdir /tmp/foo < /dev/null
b. mkdir /tmp/foo > /dev/null
c. mkdir /tmp/foo 1> /dev/null
d. mkdir /tmp/foo 2> /dev/null
(l) Which command permits you to know how many connections (in digits only) are
currently being used by user “root”? (1mk)
a. who|grep root|wc –l
b. who > grep root|wc –l
c. who|grep root>wc -l
d. who|grep >/dev/null|wc -l
e. grep root|who|wc -l
f. wc -l|grep root|who
g. wc -l<grep root<who
(m) Assuming you type the following commands:
$ls <enter>
abc abc1 abc11 abc13 abc2 abc3. What will be the output of the
following command? $ls abc[13]<enter> (1mk)
a. abc1 abc3
b. abc1 abc2 abc3 abc13
c. abc1 abc13 abc3
d. abc1 abc2 abc3
e. abc abc1 abc13 abc3
(n) Which command “find” corresponds to the following search? (1mk)
Content of the directory:
-rw-r--r-- 1 tb00029 staff 0 Dec 27 14:48 abc
-rw-r--r-- 1 tb00029 staff 0 Dec 27 14:48 abc1
-rw-r--r-- 1 tb00029 staff 0 Dec 27 14:48 abc11
-rw-r--r-- 1 tb00029 staff 0 Dec 27 14:54 abc13
-rw-r--r-- 1 tb00029 staff 0 Dec 27 14:48 abc2
-rw-r--r-- 1 tb00029 staff 0 Dec 27 14:49 abc3
drwxr-xr-x 2 tb00029 staff 512 Dec 27 16:10 abc4
drwxr-xr-x 2 tb00029 staff 512 Dec 27 16:11 abc5
Result of the ‘find’ command:
drwxr-xr-x 2 tb00029 staff 512 Dec 27 16:10 ./abc4
drwxr-xr-x 2 tb00029 staff 512 Dec 27 16:11 ./abc5
a. find . -name "abc[345]" -type d
b. find . -name "abc[345]" -type d | ls –l
c. find . -name 'abc[345]' -type d -exec ls -ld {} \;
4
d. find . -name -type d -exec ls -ld {} ";"
e. find . -name abc\[345\] -type d -exec ls -l {} \;
(o) How to search for different words in a file? (1mk)
a. grep -v ‘word1|word2’ /path/to/file
b. egrep –v ‘word1|word2’ /path/to/file
c. egrep –w ‘word1|word2’ /path/to/file
d. grep –ws ‘word1|word2’ /path/to/file
(p) Which command may give the following result? (1mk)
PID TTY TIME CMD
35622 pts/0 0:01 -ksh
46828 pts/0 0:00 ps
Tue Nov 27 14:38:26 NFT 2005
Socrates
(a) ps#date#hostname
(b) ps|date|hostname
(c) ps>date>hostname
(d) ps;date;hostname
(e) ps/date/hostname
(q) Knowing the following result:
echo $abc <enter>
Tue Dec 27 15:15:57 NFT 2005
Which command was used to initialize the variable ‘abc’ with bash or Korn shell? (1mk)
(a) set abc=date
(b) abc=date
(c) abc="date"
(d) $abc=$date
(e) abc=$(date)
(f) abc=exec(date)
(g) $abc=(date)
(r) Give the sequence of key presses and commands to enter to run the script named “s” in
background, then bring it to foreground, and finally interrupt and kill it.
(1mk)
(a) s&<enter>
ctrl-z
fg %1<enter>
stop %1<enter>
(b) s&<enter>
ctrl-z<enter>
fg %1<enter>
stop %1<enter>
kill %1<enter>
(c) s&<enter>
fg %1<enter>
ctrl-z
stop %1<enter>
kill %1<enter>
(d) s&<enter>
ctrl-z<enter>
fg %1<enter>
kill %1<enter>
(e) s&<enter>
fg %1<enter>
ctrl-z
kill %1<enter>
(s) How do you globally replace Internet with Web occurring in all lines using vi?(1mk)
a. $s/Internet/Web/g
b. $s/Internet/Web
c. $s/ Web/Internet/g
d. $s/Web/Internet
5
(t) What is symbolic equivalent to chmod 711 file? (1mk)
(1) chmod u=rw,go=x file (2) chmod u=rw,go=rx file
(3) chmod u=rwx,go=x file (4) chmod u=rwx,go=rx file
(u) Suppose you have file called 'hotel.txt' with 100 lines data, And from 'hotel.txt' you would
like to print data from line number 20 to line number 30 and store this result to file called
'hlist'. State one command line that performs this task (piping of different commands is
allowed). (2mks)
(v) You want to concatenate two files, foo1 and foo2, but also insert some text in between from
the terminal. How will you do this? (2mks)
(w) Give the command to repeat the 6th command in your bash shell’s history. (1mk)
(x) Using command substitution, write a command sequence which always prints calendar of the
current month. (3mks)
(y) Select lines 5 to 10 of a file in two ways by using head and tail. (2mks)
(z) I. List the users logged in more than once. (2mks)
II. Write one expression that will match the filename chapa, chapb, chapc, chapx, chapy.
(3mks)
III. Explain the terms: “owner”, “group” and “public or others” (3mks)


SECTION B (60mks)
Question 1: (20mks)
(a) What are TERM and SHELL? State how you evaluate their values? (3mks)
(b) Name three major differences between UNIX commands and Windows programs.
(3mks)
(c) State how to forcibly terminate (kill) the process with process ID 2401. (1mk)
(d) State three ways of knowing your home directory. (2mks)
(e) How do you list ALL processes on a UNIX system? (1mk)
(f) Give the command to delete a filename with space e.g. “my file1” (2mks)
(g) Which command will you use to archive and compress the complete directory structure dir?
(2mks)
(h) Can you create a file whose filename is . or ..? (2mks)
6
(i) Distinguish between using an example, “absolute” pathname and “relative” pathname.
(2mks)
(j) State properties of a User-Defined-Variable in shell scripting. (2mks)
Question 2: (20mks)
(a) Define the term Operating System? (2mks)
(b) State three functions of an OS. (3mks)
(c) State the major components of an UNIX OS . (3mks)
(d) How are devices represented in UNIX? (2mks)
(e) What is PATH? How do you evaluate its value? (2mks)
(f) State how UNIX divide files into different categories? (3mks)
(g) What directories do . (a single dot) and .. (two dots) represent respectively? (2mks)
(h) If mkdir foo doesn't create the directory, what could be the possible reasons? Write at least
three possible reasons. (3mks)
Question 3: (20mks)
(a) What’s a shell? (2mks)
(b) State three functions of the shell in Linux. (3mks)
(c) Identify four common UNIX shells. (2mks)
(d) State the differences between “Hard links” and “Soft links. (2mks)
(e) Study the script below and write its output. (2mks)
#!/bin/bash
echo "Pattern"
for (( i=1; i<=5; i++ ))
do
for (( j=1; j<=i; j++ ))
do
echo -n " *"
done
echo ""
done
for (( i=5; i>=1; i-- ))
7
do
for (( j=1; j<=i; j++ ))
do
echo -n " *"
done
echo ""
done
(f) What’s an inode? (2mks)
(g) Define the term “process” and state the command to execute to show running processes
(2mks)
(h) Define the term “daemons” and state two examples used in Linux system (2mks)
(i) What’s the advantage of executing a program in the background? (1mk)
(j) State the one command statement that backups up all files in the current directory in to the
folder called backup in the parent directory and the backup runs in the background.
(2mks)

Question 4: (20mks)
(a) Using shell commands, write a script to find out largest number from given three numbers.
The numbers are supplied as command line arguments. Print error if sufficient arguments are
not supplied. (7mks)
(b) Using information below stored in file called purchases, write an awk script that will print
the total cost of each item in the fifth column. (6mks)
No. Item Qty Price
1 Pen 5 20.00
2 Pencil 10 2.00
3 Rubber 3 3.50
4 Cock 2 45.50
(c) Write a shell script to reverse any given positive number (more than 2 digits). (7mks)

Question 5: (20mks)
(a) Using case statement with while command, write a shell script that reads from the file
myfile, and for each line, it prints out what language of greeting it thinks is being used. Each
line must end with a newline. (10mks)
NB; The greeting languages are: hello for English; howdy for American; gday for Australia;
bonjour for French; guten tag for German.
(b) State and explain FIVE functions of a system administrator. (10mks)






More Question Papers


Popular Exams


Mid Term Exams

End Term 1 Exams

End Term 3 Exams

Opener Exams

Full Set Exams



Return to Question Papers