Unix Mock Test


This section presents you various set of Mock Tests related to Unix Framework. You can download these sample mock tests at your local machine and solve offline at your convenience. Every mock test is supplied with a mock test key to let you verify the final score and grade yourself.

Questions and Answers

Unix Mock Test I

Q 1 - Choose the odd one out.

A - csh

B - bsh

C - ksh

D - Kernel

Answer : D

Explanation

Kernel is the core part of the OS and is odd one the rest are popular shells.

Q 2 - What is the option to create symbolic link for a file?

A - –s

B - –l

C - –f

D - None of the above.

Answer : A

Explanation

-s is the option to create a symbolic/soft link and applicable for only files.

Q 3 - What is the option to create hard link for a directory?

A - –s

B - –l

C - –f

D - None of the above.

Answer : D

Explanation

It is error to create a hard link for a directory.

Q 4 - The following command can list out all the current active logins.

A - whoami

B - who am i

C - who

D - None of the above.

Answer : C

Explanation

who lists out all the current active logins with the associated terminal types, time and host machine name.

Q 5 - Choose the command to print the current working directory

A - cwd

B - pwd

C - wd

D - nwd

Answer : B

Explanation

pwd (present working directory).

Q 6 - What is the file descriptor number which represents the STDOUT?

A - 0

B - 1

C - 2

D - None of the above.

Answer : B

Explanation

0-STDIN, 1-STDOUT & 2-STDERR

Answer : C

Explanation

Dot dot (..) represents parent directory and Dot (.) represents current working directory.

Q 8 - Identify the environment variable which designates secondary prompt.

A - PP1

B - SP2

C - PS1

D - PS2

Answer : D

Explanation

PS2 stands for primary string two.

Answer : D

Explanation

A program in the execution state is called as process.

Answer : C

Explanation

The parent process id of a child process.

Q 11 - Which key combination can yank a line in vi?

A - yw

B - yc

C - yy

D - yl

Answer : C

Explanation

Yanking is the process of holding a text in the buffer.

Q 12 - She-bang line in a shell script begins with__

A - #

B - #!

C - !#

D - None of the above.

Answer : B

Explanation

It tell the system to use which shell for executing the script file.

Q 13 - How does a comment can begin in a shell script file.

A - Beginning with #

B - Beginning with $

C - Beginning with !

D - None of the above.

Answer : A

Explanation

A comment line begin with # (pound symbol) and is ignored by the shell.

Answer : D

Explanation

We can provide the permission values in octal number system and 888 is not a valid octal number.

Q 15 - Which shell variable holds the first command line argument for a shell script?

A - $0

B - $1

C - #0

D - None of the above

Answer : B

Explanation

$0 represent the shell script file name itself. Starting with $1, are actual command line arguments sent to the shell script.

Q 16 - Let a = 5, b = 6. Choose the proper command to perform multiplication?

A - expr $a * $b

B - expr $a \* $b

C - $(a*b)

D - None of the above.

Answer : B

Explanation

As * hold special meaning suppress it by escaping with \.

Q 17 - Which filter can be applied on lines of text for arranging in ascending or descending order?

A - sort

B - arrange

C - collate

D - None of the above.

Answer : A

Explanation

Sort command, a filter used to sort the text in Lexi logical or numerical order.

Q 18 - Which shell operator can be used to place a command to execute in background?

A - |

B - &

C - &&

D - >

Answer : B

Explanation

Syntax is command &.

Q 19 - We can kill any background executing process.

A - True

B - False

Answer : B

Explanation

False. We can kill only the processes for which we are owner.

Q 20 - Which of the following is correct to create an alias name for 'ls' as 'list'?

A - alias list=”ls”

B - alias list “ls”

C - alias “list” as “ls”

D - alias “ls” as “list”

Answer : A

Explanation

Syntax is alias alias-name=”command”.

Q 21 - Choose the correct from below to search for lines beginning with the pattern using grep.

A - ^pattern

B - pattern^

C - $pattern

D - pattern$

Answer : A

Explanation

The pattern can be enclosed in single quotes to suppress meaning of all the meta-characters special meanings.

Q 22 - Copy all the .doc extension files with file name having only 3 characters into the directory called “confi”, which is in parent directory.

A - cp ???.doc ../confi

B - cp [1-3].doc ../confi

C - cp ???.doc /confi

D - None of the above.

Answer : A

Explanation

??? -> to match for any 3 characters. Dot dot (..) represents parent directory.

Q 23 - Which command can be used to remove a non-empty directory?

A - rmdir

B - rd

C - ddir

D - rm

Answer : D

Explanation

rmdir can be used only if the directory is empty. We can remove the directory if non-empty using recursive option with ‘rm’, as a directory is even a file for UNIX/Linux.

Q 24 - Choose the option to remove write permission for group & others for a file “a.txt”.

A - Select disable write for group and others where file=”a.txt”

B - chmod go-w a.txt

C - chmod w-go a.txt

D - chmod go=”r-x” a.txt

Answer : B

Explanation

Q 25 - Choose the command to list only the file “error.txt”

A - ls *err*.txt

B - ls e*.txt

C - ls error.???

D - ls error.txt

Answer : D

Explanation

Answer Sheet

Question Number Answer Key
1 D
2 A
3 D
4 C
5 B
6 B
7 C
8 D
9 D
10 C
11 C
12 B
13 A
14 D
15 B
16 B
17 A
18 B
19 B
20 A
21 A
22 A
23 D
24 B
25 D
unix_questions_answers.htm
Advertisements