Genesis Insoft The name you can TRUST
twitterlogo facebooklogo
Home  |  Contact Us |  Careers
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"

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

Answer to Question 1

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 ' '

Answer to Question 2

Question 3

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

  1. echo $#
  2. echo $@
  3. echo $?
  4. 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

  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"

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

  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

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?

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

Answer to Question 6

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

Answer to Question 7

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 ' '

Answer to Question 8

Question 9

What is the signal number to terminate a process?

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

Answer to Question 9

Question 10

Console is a

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

Answer to Question 10

Question 11

When you login to Unix system kernel starts

  1. Init
  2. Getty
  3. Device files
  4. 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 ' '

  1. 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?

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

Answer to Question 13

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

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

  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

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

  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

Answer to Question 16

fQuestion 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

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

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

Answer to Question 18

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

Answer to Question 19

Question 20

The command which waits for user to login is?

  1. Init
  2. Getty
  3. Kernel
  4. 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

Back to question 14

Answer 15 - D

Back to question 15

Answer 16 - D

Back to question 16

Answer 17 - B

Back to question 17

Answer 18 - C

Back to question 18

Answer 19 - C

Back to question 19

Answer 20 - B

Back to question 20

Copyright © 2000 to 2024 Genesis InSoft Limited. All Rights Reserved.