This set of Unix Multiple Choice Questions & Answers (MCQs) focuses on “Shell Offerings”.
1. set command by default displays the variables in the current shell.
Explanation: 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?
Explanation: 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.
b) log out
Explanation: 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.
Explanation: A set option is turned off with set +o keyword. For example, to reverse the noclobber feature use the following command:
$ set +o noclobber.
5. The ____ acts as a shorthand representation of the home directory.
Explanation: 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.
Explanation: 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?
b) rc file
Explanation: 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?
d) HISTISIZE and HISTFILESIZE
Explanation: 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?
b) /cvf [enter]
Explanation: 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.
Sanfoundry Global Education & Learning Series – Unix.
To practice all areas of Unix, here is complete set of 1000+ Multiple Choice Questions and Answers.