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

How will you separate one command from another if you want to put several commands on the same line?

  1. :
  2. ||
  3. -a
  4. ;

Answer to Question 1

Question 2

If the following echo command is used, what would be the output

    Echo This is a test of * meta character in Unix operating system

  1. This is a test for * meta character in Unix operating system
  2. The meta character * is replaced by a list of all your files
  3. Improper usage of meta character in echo command
  4. Syntax error

Answer to Question 2

Question 3

Contents of file "test" are as follows

    Echo ${1? "This is a test for argument"} is the only argument

    What is the output, if you execute the following file

  1. Bad substitution
  2. This is a test for argument
  3. Test is the only argument
  4. This is a test for argument is the only argument

Answer to Question 3

Question 4

Which of following shell variables provides information of the command being executed and its PID?

  1. $! and $0
  2. $0 and $$
  3. $$ and $!
  4. $$ and $-

Answer to Question 4

Question 5

What is the output of the following command if file one is undefined?

    sort one > one.sort 1>&2 two

  1. throws an error on the standard output and writes to file called two, stating file or directory does not exist
  2. throws an error only on the standard output, stating file or directory does not exist
  3. the standard error is redirected to the file called two, stating file or directory does not exist
  4. None of the above

Answer to Question 5

Question 6

What is the output of the following command assuming the variable called name is defined as
Name=Genesis
: ${name?' is the name of our organization'}

  1. Syntax error
  2. Genesis is the name of our organization
  3. Nothing, because it is a do nothing command
  4. Wrong usage of : , $ and ? in one statement

Answer to Question 6

Question 7

Which of the following shell command is used as a comment in Unix

  1. //
  2. :
  3. #
  4. Both A and B

Answer to Question 7

Question 8

To find the files containing word "printf" in the system

  1. find / -name * -exec grep "printf"
  2. find / -name "*" -exec grep "printf" {} \;
  3. find / -name "*" -exec grep -l "printf" {} \;
  4. find / -name "*" -exec ls -l {} \;

Answer to Question 8

Question 9

What is the significance of fork function

  1. Kills an existing process
  2. Temporarily half an existing process
  3. Create a new process, killing the previous process
  4. Create a new process

Answer to Question 9

Question 10

On successful completion of fork()

  1. It returns a value of 0 to the child process and also returns process ID of the child process to the parent process
  2. It returns a value of -1 to the parent process, with no creation of child process
  3. It returns a value of 0 to the parent process and also returns process ID of the child process to the parent process
  4. It returns a value of -1 to the child process and also returns process ID of the child process to the parent process

Answer to Question 10

Question 11

What is the output of the following code

    main()
    {
        printf("Line1 ");
        fork();
        printf("Line2 ");
    }

  1. Line1 Line2
  2. Line1 Line2 Line2
  3. Line1
  4. Line2 Line1

Answer to Question 11

Question 12

What is the output of the following code

    main()
    {
        printf("Line1 ");
        execl("/bin/date","date",0);
        printf("Line2 ");
    }

  1. Line1 followed by date
  2. Line1, date followed by Line2
  3. Line1 followed by Line2
  4. Syntax error

Answer to Question 12

Question 13

The /etc/passwd file can be updated only by superusers. But a ordinary user can update his password through /bin/passwd executable file, because

  1. The owner can change his password
  2. Temporary permission is given to update /etc/passwd
  3. Superuser gives permission to change his passwd
  4. None of the above

Answer to Question 13

Question 14

Which command waits until all background processes known to the current shell have been terminated?

  1. sleep
  2. stop
  3. wait
  4. continue

Answer to Question 14

Question 15

What does wait() system call return to all parent process, when a child process is created by fork()?

  1. PID of the child process
  2. Exit status of the child process
  3. Returns zero or one
  4. Both A and B

Answer to Question 15

Question 16

Which command compares two text files?

  1. diff
  2. compare
  3. write
  4. tell

Answer to Question 16

fQuestion 17

What is the output of the following statement?
    echo */*

  1. displays all files in all directories
  2. displays only the files in the current directory
  3. displays only the directories
  4. syntax error

Answer to Question 17

Question 18

If you want to display message at the time of login, which of the following files do you edit?

  1. /etc/passwd
  2. /etc/motd
  3. /etc/news
  4. /etc/msg

Answer to Question 18

Question 19

Which of the following category of user can send message at the time of login?

  1. Only the superuser
  2. Only the users
  3. Only the groups
  4. Others

Answer to Question 19

Question 20

What is the output of the following shell script?

    t=`cat /etc/passwd | grep -s $1`
    echo $t
    if [ $? -eq 1 ] then
        Echo " $1 is not created"
    else
        Echo " $1 is created"
    fi

  1. Syntax error
  2. Improper usage /etc/passwd, because you cannot edit /etc/passwd (read permission is denied)
  3. Searches for the name given at the command line in the /etc/passwd and on success displays the message name is not created
  4. Searches for the name given at the command line in the /etc/passwd and on success displays the message name is created

Answer to Question 20

Answers

Answer 1 - D

Back to question 1

Answer 2 - B

Back to question 2

Answer 3 -  B

Back to question 3

Answer 4 - B

Back to question 4

Answer 5 - A

Back to question 5

Answer 6 - C

Back to question 6

Answer 7 - A

Back to question 7

Answer 8 - C

Back to question 8

Answer 9 - D

Back to question 9

Answer 10 - A

Back to question 10

Answer 11 - B

Back to question 11

Answer 12 - A

Back to question 12

Answer 13 - B

Back to question 13

Answer 14 - C

Back to question 14

Answer 15 - D

Back to question 15

Answer 16 - A

Back to question 16

Answer 17 - A

Back to question 17

Answer 18 - B

Back to question 18

Answer 19 - A

Back to question 19

Answer 20 - D

Back to question 20

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