CHUKA UNIVERSITY
FORTH YEAR SECOND SEMESTER EXAMINATIONS FOR
BACHELOR OF APPLIED COMPUTER SCIENCE
ACMP 428: UNIX SYSTEMS ADMINISTRATION AND
PROGRAMMING (LINUX)
CANDIDATE INSTRUCTIONS
1 Answer all questions in section A and any other two
questions from section B.
2 No Reference Material is allowed in the exam Room.
3 Write legibly on Both sides of question paper.
4 All Mobile phones should be switched off in the exam room.
SECTION A (COMPULSORY)
QUESTION 1(COMPULSORY) [30 MARKS]
a) Using an example, explain the use of the following command
on files.
$ sort record.txt | uniq
(4marks)
b) Write a shell script using FUNCTIONS that prompt a user to
enter his first name, and two numbers. it then prints the name
and the sum of two numbers
(6marks)
c) Differentiate between echo and echo {0,1}{0,1}{0,1}
when keyed on the command prompt.
(4marks)
d) Explain what the following commands does in Linux.
i) df
(2marks)
ii) uname
(2marks)
iii) gzip
(2marks)
e) Explain FIVE shell build in variables.
(5marks)
f) Write a shell script called leaptest that prompts a user to
enter the year in 4 digits and test if the year is leap or not (a
leap year is divisible by 4) (5marks)
SECTION B (Answer two question from this section)
1
QUESTION 2 [20 MARKS]
a) Write a shell script that prints the following output
(8marks)
0
1 0
2 10
3 210
4 3210
b) Explain the usage of the following Linux commands in TCP/IP
management
i) route -n
(2marks)
ii) netstart -t
(2marks)
iii) ifconfig -a
(2marks)
c) Explain what happens when each of the following codes are
keyed in a bash console. Hence write the output.
i) declare -i number
number=2+4*10
echo $number
(2marks)
ii) another=2+4*10
echo $another
(2marks)
iii) number="foobar"
echo $number
(2marks)
QUESTION 3 [20 MARKS]
a) Outline TWO ways on how to set permissions of a file such that
the user has all the privileges, while group and others have only
read and execute privileges.
(6marks)
b) Using pipes, display all lines of files list1 and list2 that contains
letter ‘p’, and sort the results
(3marks)
c) Explain the following Linux installation methods
i) CD/ DVD installation
ii) Network installation
2
iii) Kick-start installation
(6marks)
d) Outline the function of the following directories in Linux operating
system
i) /usr/bin
ii) /boot
iii) /dev
iv) /etc
v) /media
(5marks)
QUESTION 4 [20 MARKS]
a) Write a shell script that will prompt a user to enter a number,
then it returns the factorial of the number.
(7marks)
b) Using an example, Explain the following redirection commands
i) P>&m
(2marks)
ii) P>>somefile
(2marks)
iii) find . -name 'my*' 2>error.log
(3marks)
c) Explain SIX special variables that can be used in shell scripting.
(6marks)
QUESTION 5 [20 MARKS]
a) Tar command can be used with several options in Linux.
Explain FIVE options that can be used with the tar command.
(5marks)
b) Write a shell script that prompts a user to enter four numbers.
It then finds the sum, the average and the product of the four
integers entered. (7marks)
c) Write a shell script using if…fi statement, and test command to
test for the following: -
(8marks)
If a file is not empty,
If it’s a file and a not directory,
If a file exists,
If it’s a directory and not a file,
3
If a file is read only,
If file is executable