Unix Question Bank / FAQs
This is a mock Exam for the Unix programmers. It is created by Genesis InSoft Limited (admin@genesisinsoft.com) and may be freely
distributed so long as it is unmodified. Please email us if you have any corrections or
comments.
Question1
What is the output of the program?
echo "Give input \c";read str
set $str
echo " Give the word \c";read word
count=0
for i in $*
do
if [ $i -eq $word ]
then
count=`expr
$count + 1`
fi
done
echo $count
if the input is "This is a test to test your
knowledge"
and the given word to search is "test"
- Syntax error
- 8
- 2
- 9
Answer to Question 1
Question 2
Which of the following provides information about the current users and their
terminal types?
- who | tr -s ' ' | cut -f1,2 -d ' '
- who | tr -s ' ' | cut -f1-2 -d ' '
- who | cut -f1-2 -d ' '
- who | cut -f1,2 -d ' '
Answer to Question 2
Question 3
How can you find out the exit status of a shell script using exit?
- echo $#
- echo $@
- echo $?
- echo $??
Answer to Question 3
Question 4
What is the output of the following shell script, if a file "test"
exists?
cat test |
tr -sc A-Za-z |
sort |
uniq -c |
sort -n |
tail
displays the last ten lines from the file "test"
displays the first ten lines from the file "test"
displays only the last line from the file "test"
displays only the first line from the file "test"
Answer to Question 4
Question 5
What is the output of the following shell script?
While true
Do
Sleep 5
Echo "\007 Check it out again
\007"
Done
- After every 5 seconds it displays the message \007 Check it out again \007
- After every 5 seconds it displays the message Check it out again in bold
letters
- After every 5 seconds it displays the message Check it out again with a
beep sound
- None of the above
Answer to Question 5
Question 6
Which of the following option is used to find out whether a given name is the
name of a file or a directory?
- -fd
- -d
- -ff
- -f
Answer to Question 6
Question 7
Which command displays maximum of 10 lines from the end of the file?
- Head
- Tail
- Both A and B
- None of the above
Answer to Question 7
Question 8
Which of the following gives the count of number of links of a particular
file?
- ls -l |grep filename |cut -f2 -d ' '
- ls |grep filename | tr -s ' ' | cut -f2 -d ' '
- ls |grep filename | cut -f2 -d ' '
- ls -l |grep filename | tr -s ' ' | cut -f2 -d ' '
Answer to Question 8
Question 9
What is the signal number to terminate a process?
- 1
- 9
- 3
- 12
Answer to Question 9
Question 10
Console is a
- Ordinary file
- Character based file
- Stream
- None of the above
Answer to Question 10
Question 11
When you login to Unix system kernel starts
- Init
- Getty
- Device files
- Both A and B
Answer to Question 11
Question 12
What does the following statement perform?
who -u | grep unix | tr -s ' ' | cut -f6 -d ' '
- It will search for all the user logged, and return their login time
It will search for all the user logged, and return their ideal time
It will search for all the user logged, and return the time spend by them in
the lab
None of the above
Answer to Question 12
Question 13
Which command displays the first few lines of a particular file?
- grep
- tail
- search
- head
Answer to Question 13
Question 14
What is the significance of execl()?
- It kills the original process and start a new process
- It continues the original process by overlaying memory with a new set of
instructions
- It does not kill the original process but creates a copy of the existing
one and starts a new process
- None of the above
Answer to Question 14
Question 15
What would be the output of the following shell script "Display",
if the files one, two and three exist
echo Displaying the contents of all the files
cat "$*"
It is executed as: sh Display one two three
- displays the contents of the file one, two and three
- displays the contents of the file one and two
- displays the contents of the file two and three
- displays the message cannot open file one two and three
Answer to Question 15
Question 16
// Old ones follow
What does the following shell script do?
echo "Enter the name ";read name
for name
do
if [ -d $name
]
then
echo "YES"
elif [ -f
$name ]
then
echo "NO"
else
echo "JUNK"
fi
done
- displays YES if the given name is the name of a directory
- displays NO if the given name is the name of a file
- displays JUNK if the given name is neither a file nor a directory
- All of the above
Answer to Question 16
fQuestion 17
Which of the following command compares two files, and displays bytes and
line number if there are differences?
- diff
- cmp
- comm
- ed
Answer to Question 17
Question 18
What is the exit status of the following, if file "one" is existing
and the other "file" two in not existing?
cmp one two
- 0
- 1
- 2
- 4
Answer to Question 18
Question 19
When unix is adapted to a new kind of computer, what needs to be done?
- Commands has to be changed
- Command interpreter (shell) has to be modified
- Kernel has to be modified
- None of the above
Answer to Question 19
Question 20
The command which waits for user to login is?
- Init
- Getty
- Kernel
- Getttydef
Answer to Question 20
Answers
Answer 1 - B
Back to question 1
Answer 2 - A
Back to question 2
Answer 3 - C
Back to question 3
Answer 4 - A
Back to question 4
Answer 5 - C
Back to question 5
Answer 6 - D
Back to question 6
Answer 7 - B
Back to question 7
Answer 8 - D
Back to question 8
Answer 9 - B
Back to question 9
Answer 10 - B
Back to question 10
Answer 11 - D
Back to question 11
Answer 12 - B
Back to question 12
Answer 13 - D
Back to question 13
Answer 14 - B
Answer 15 - D
Back to question 15
Answer 16 - D
Back to question 16
Answer 17 - B
Answer 18 - C
Answer 19 - C
Back to question 19
Answer 20 - B
Back to question 20
|