Essential Shell Programming

This MCQ-formatted quiz focuses on shell programming using read command and command-line arguments, logical operators and conditional execution, using test and [ ] to evaluate expressions, case and expr commands, administrator specific commands and privileges.

Start Quiz

Which of the following operators are used for logical execution?

||

&&

%%

&& and ||

When we use &&, the second command is executed only if the first succeeds. True or false?

True

False

When we use ||, both the commands are executed. True or false?

True

False

The syntax for using && is

cmd1 && cmd2

cmd1 cmd2 &&

cmd1 & cmd2&

cmd1

__ is used to perform decisions depending on the fulfilment of specific criteria.

if

else

for

if and else

The second set of the three permissions (r-) indicates that

Group has read permission only

Other has read permission only

Owner has read permission only

Group has write permission only

None of the above

Whilst working with the mail command, which command is used to save mail in a separate file?

s

r

w

d

None of the above

Which option is used with the sort command to start sorting after the nth column of the (m+l)th field?

-m.n

+m.n

+ n.m+1

+(m+l).n

None of the above

Which of the following commands is used to copy a file ‘wb’ from the program’s directory into a file called ‘wbx’ in the misc directory?

copy programs/wb misc/wbx

cp programs/wb misc/wbx

tar programs/wb misc/wbx

copy a:programs/wb b:misc/wbx

None of the above

Which of the following files contains information related to password ageing?

Shadow

Password

Profile

All of the above

None of the above

To know the exit status of a command, we use

$$

$*

$?

$-

Which of the following is not a special parameter used by the shell?

$$

$*

$?

$-

__ is used with ‘if-else’ statements to check more than two conditions.

while

for

elif

for

Every ‘if’ is closed with a corresponding

else

fi

if

else if

The name of the script is stored in which special parameter?

$1

$0

$#

$*

Quiz/Test Summary
Title: Essential Shell Programming
Questions: 15
Contributed by:
Ivan