250+ TOP MCQs on Shell Offerings and Answers

Unix Multiple Choice Questions on “Shell Offerings”.

1. set command by default displays the variables in the current shell.
a) True
b) False

Answer: a
Clarification: The set statement by default displays the variables in the current shell, but in bash and Korn shell, it can make several environment settings with -o option.

2. Which one of the following keyword is used with the set command to avoid overwrite existing file?
a) nooverwrite
b) ignore
c) clobber
d) noclobber

Answer: d
Clarification: The shell’s > symbol overwrites (clobber) an existing file, and to prevent such accidental overwriting, e have to use noclobber argument in the following way:

$ set  -o  noclobber        // no more overwriting file with >

3. To prevent accident logging out, we can use ____ as a keyword with the set command.
a) noclobber
b) log out
c) ignoreeof
d) ignore

Answer: c
Clarification: It may happen that sometimes when we press the Ctrl-d with intent to terminate standard input, but end up logging out of the system. The ignoreeof keyword offers protection from accidental logging out.

$ set  -o  ignoreeof        //no more logging out using ctrl-d

4. To reverse any setting updated by set command we can use ____ symbol.
a) –
b) /
c) +
d) $

Answer: c
Clarification: A set option is turned off with set +o keyword. For example, to reverse the noclobber feature use the following command:

5. The ____ acts as a shorthand representation of the home directory.
a) $
b) ~
c) “”
d) %

Answer: b
Clarification: The ~ acts as a shorthand representation of the home directory. When the ~ (tidle) is followed by a login name, the shell understands the entire argument as the absolute pathname of the login directory. Thus when the shell encounters the following command line, it switches the Sharma’s home directory.

$ cd ~ sharma         //effectively becomes $HOME/sharma

6. Every shell uses at least one startup script in the user’s home directory, which is executed when the user logs in.
a) True
b) False

Answer: a
Clarification: Every shell uses at least one startup script in the user’s home directory. This script is executed when the user logs in. Some shells also make use of a separate file that is run before logging out. We can look for these files in our home directory.

.profile (Bourne shell)
.profile and .kshrc (Korn shell)
.bash_profile or .bashrc (bash shell)

7. Which file is executed every time a second shell is called up?
a) .profile
b) rc file
c) .script
d) env.file

Answer: b
Clarification: There is no rc file in Bourne, but bash and Korn shell use one. This file is defined by an environment variable (BASH_ENV in bash and ENV in Korn). This rc file is executed every time a second shell is called up (when running a shell script, for instance).

8. Which of the following are history variables?
a) HISTISIZE
b) HISTFILESIZE
c) HISTORY
d) HISTISIZE and HISTFILESIZE

Answer: d
Clarification: The history list is maintained in memory. Bash uses two separate variables HISTSIZE and HISTFILESIZE for setting the size of the history list in memory and on disk. For example,

$ HISTSIZE=500                      // bash and Korn
$ HISTFILESIZE=1000                // bash only -determines the size of disk file

9. Which one of the following command will search history list for the previous command having the last occurrence of string cvf?
a) /cvf
b) /cvf [enter]
c) /bkw
d) !cvf

Answer: a
Clarification: We can also use vi’s search technique to recall previous commands from the history list. Even we can also search in the reverse direction, using /pattern sequence.

Leave a Reply

Your email address will not be published.