Wednesday, August 4, 2010

Unix Questions - Set 1-4

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"

  1. Syntax error
  2. 8
  3. 2
  4. 9

Question 2

Which of the following provides information about the current users and their terminal types?

  1. who | tr -s ' ' | cut -f1,2 -d ' '
  2. who | tr -s ' ' | cut -f1-2 -d ' '
  3. who | cut -f1-2 -d ' '
  4. who | cut -f1,2 -d ' '

Question 3

How can you find out the exit status of a shell script using exit?

  1. echo $#
  2. echo $@
  3. echo $?
  4. echo $??

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

  1. displays the last ten lines from the file "test"
  2. displays the first ten lines from the file "test"
  3. displays only the last line from the file "test"
  4. displays only the first line from the file "test"

Question 5

What is the output of the following shell script?

While true

Do

Sleep 5

Echo "\007 Check it out again \007"

Done

  1. After every 5 seconds it displays the message \007 Check it out again \007
  2. After every 5 seconds it displays the message Check it out again in bold letters
  3. After every 5 seconds it displays the message Check it out again with a beep sound
  4. None of the above

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?

  1. -fd
  2. -d
  3. -ff
  4. -f

Question 7

Which command displays maximum of 10 lines from the end of the file?

  1. Head
  2. Tail
  3. Both A and B
  4. None of the above

Question 8

Which of the following gives the count of number of links of a particular file?

  1. ls -l |grep filename |cut -f2 -d ' '
  2. ls |grep filename | tr -s ' ' | cut -f2 -d ' '
  3. ls |grep filename | cut -f2 -d ' '
  4. ls -l |grep filename | tr -s ' ' | cut -f2 -d ' '

Question 9

What is the signal number to terminate a process?

  1. 1
  2. 9
  3. 3
  4. 12

Question 10

Console is a

  1. Ordinary file
  2. Character based file
  3. Stream
  4. None of the above

Question 11

When you login to Unix system kernel starts

  1. Init
  2. Getty
  3. Device files
  4. Both A and B

Question 12

What does the following statement perform?

who -u | grep unix | tr -s ' ' | cut -f6 -d ' '

  1. It will search for all the user logged, and return their login time
  2. It will search for all the user logged, and return their ideal time
  3. It will search for all the user logged, and return the time spend by them in the lab
  4. None of the above

Question 13

Which command displays the first few lines of a particular file?

  1. grep
  2. tail
  3. search
  4. head

Question 14

What is the significance of execl()?

  1. It kills the original process and start a new process
  2. It continues the original process by overlaying memory with a new set of instructions
  3. It does not kill the original process but creates a copy of the existing one and starts a new process
  4. None of the above

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

  1. displays the contents of the file one, two and three
  2. displays the contents of the file one and two
  3. displays the contents of the file two and three
  4. displays the message cannot open file one two and three

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

  1. displays YES if the given name is the name of a directory
  2. displays NO if the given name is the name of a file
  3. displays JUNK if the given name is neither a file nor a directory
  4. All of the above

Question 17

Which of the following command compares two files, and displays bytes and line number if there are differences?

  1. diff
  2. cmp
  3. comm
  4. ed

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

  1. 0
  2. 1
  3. 2
  4. 4

Question 19

When unix is adapted to a new kind of computer, what needs to be done?

  1. Commands has to be changed
  2. Command interpreter (shell) has to be modified
  3. Kernel has to be modified
  4. None of the above

Question 20

The command which waits for user to login is?

  1. Init
  2. Getty
  3. Kernel
  4. Getttydef

 

Answers

Answer 1 - B

Answer 2 - A

Answer 3 - C

Answer 4 - A

Answer 5 - C

Answer 6 - D

Answer 7 - B

Answer 8 - D

Answer 9 - B

Answer 10 - B

Answer 11 - D

Answer 12 - B

Answer 13 - D

Answer 14 - B

Answer 15 - D

Answer 16 - D

Answer 17 - B

Answer 18 - C

Answer 19 - C

Answer 20 - B

No comments:

Post a Comment