Unix Multiple Choice Questions on “Shell Basics”.
1. Shell provides us with an interface to the operating system.
Clarification: Shell provides us with an interface to communicate with the UNIX operating system. It is also called command interpreter because it gathers our input and executes commands accordingly. In simple words, it is actually the interface between the user and the kernel and has the capability of translating commands into actions.
2. On a UNIX system, there can be ____ shells running simultaneously.
Clarification: Even though there is only one kernel running on our system, there can be multiple shells running in action –one for each user who is logged in. As we know that computers don’t have any inherent capability of translating commands into actions, this piece of a task is performed by the command interpreter –known as the shell.
3. There can be multiple kernels on a single UNIX system.
Clarification: There cannot be multiple kernels running on a single UNIX system, however, there can be multiple shells in action –each for a user who is logged in. There is only and only one kernel with which every shell interact in a UNIX system.
4. The prompt issued by the shell is called ______
b) command translator
c) command prompt
d) command executor
Clarification: The prompt issued by the shell is called a command prompt which is represented by $. However, the symbol for the command prompt differs according to the shell on which we are working. When the command prompt is displayed, we can type any command followed by an Enter for performing our task.
5. In UNIX there are ___ major types of shells.
Clarification: In UNIX, there are two major types of shells.
• Bourne shell
• C shell
These two categories are further divided into subcategories.
Bourne shell has the following subcategories:-
• Bourne shell (sh)
• Korn shell (ksh)
• Bourne Again shell (bash)
• POSIX shell (sh)
C shell has the following subcategories:-
• C shell (csh)
• TENEX/TOPS C shell (tcsh)
6. What is the default symbol for command prompt in Bourne shell?
Clarification: If we are using bourne shell on our system, then the default prompt will be represented by $.
7. What is the default symbol for command prompt in C shell?
Clarification: If we are using C shell on our system, then the default prompt will be represented by %.
8. Which one of the following command will display the name of the shell we are working on?
a) echo shell
b) echo $
c) echo $SHELL
d) echo $$
Clarification: When we run the command echo $SHELL, it will display the current shell on which we are working. The output of the command is the absolute pathname of the shell’s command file. If $SHELL evaluates to/bin/bash, our login shell is bash.
9. Which shell is the most common and best to use?
a) Korn shell
b) POSIX shell
c) C shell
d) Bash shell
Clarification: Bash is near POSIX-compliant and probably the best shell to use. It is the most common shell used in UNIX systems. Bash is an acronym which stands for –“Bourne Again SHell”. It was first released in 1989 and was distributed widely as the default login shell for most Linux distributions.
10. Which command does not terminates unless we log out of the system?
Clarification: When we log on to a UNIX system, we first see a prompt. This prompt remains there until we key in something. Even when we think the system is idling, a UNIX command is always running at the terminal. This command is known as the shell. The shell is with us all the time and doesn’t terminates unless we log out.
11. In Shell’s interpretive cycle, the shell first scans for ____ in the entered command.
Clarification: In Shell’s interpretive cycle, the shell first issues a prompt and waits for the user to enter the command. After the command is entered, the shell scans the command line for meta-characters and expands the abbreviations (like the * in rm*) to recreate a simplified command line.
12. Which of the following expression is a correct wildcard pattern if we want an expression in which the last character is not numeric?
Clarification: Wildcards are used for pattern matching. The command *[!0-9] will match all expression containing any characters except that the last character entered is not numeric. Here ‘!’ is used for NOT.
*[!0] // last characters should not be 0 in the expression *[0-9] // any expression where the last character is a numeric [0-9] // expression should only contains digits *[!0-9] // the last character should not be numeric in the expression
13. The shell waits for the command to complete and normally can’t do any work while the command is executing.
Clarification: After the shell has issued the prompt and the scanning for meta-characters has been performed it passes the command on the command line to the kernel for execution. After that, the shell waits for the command to complete its execution and normally we can’t do any other work while the command is executing.
14. Which of the following is/are true about Shell?
a) Shell is a multi-faceted program
b) Shell is a command interpreter
c) Shell provides us with an environment to work in
d) Shell is a multi-faceted, command interpreter and provides an environment to work in
Clarification: Shell is the agency that sits between the user and the UNIX system. It is a unique and multi-faceted program. It is also called command-interpreter because it interprets our command entered. It is also a programming language. From another point of view, the shell also provides us with an environment to work in.
15. To change the login shell in some system (like Linux) we can use ____ command.
Clarification: Some systems, offer the chsh command that can change the user’s login shell. This command will accept the full pathname of an executable file on the system. -s option is used with chsh command. However, it will issue a warning if the shell is not listed in the /etc/shells file. For example,
chsh -s /bin/korn abd //set user abd’s login shell to /bin/Korn