Unix Questions and Answers – Shell Basics

«
»

This set of Unix Multiple Choice Questions & Answers (MCQs) focuses on “Shell Basics”.

1. Shell provides us with an interface to the operating system.
a) True
b) False
View Answer

Answer: a
Explanation: 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.
advertisement

2. On a UNIX system, there can be ____ shells running simultaneously.
a) 1
b) 2
c) many
d) 4
View Answer

Answer: c
Explanation: 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.
a) True
b) False
View Answer

Answer: b
Explanation: 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 ______
a) prompt
b) command translator
c) command prompt
d) command executor
View Answer

Answer: c
Explanation: 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.
a) 2
b) 3
c) 4
d) many
View Answer

Answer: a
Explanation: 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)
advertisement

6. What is the default symbol for command prompt in Bourne shell?
a) $
b) %
c) #
d) @
View Answer

Answer: a
Explanation: 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?
a) $
b) %
c) #
d) @
View Answer

Answer: b
Explanation: 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 $$
View Answer

Answer: c
Explanation: 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
View Answer

Answer: d
Explanation: 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?
a) history
b) shell
c) echo
d) login
View Answer

Answer: b
Explanation: 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.
advertisement

11. In Shell’s interpretive cycle, the shell first scans for ____ in the entered command.
a) characters
b) priority
c) meta-characters
d) wildcards
View Answer

Answer: c
Explanation: 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?
a) *[!0]              
b) *[0-9]              
c) [0-9]              
d) *[!0-9]             
View Answer

Answer: d
Explanation: 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.
a) True
b) False
View Answer

Answer: a
Explanation: 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
View Answer

Answer: d
Explanation: 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.
advertisement

15. To change the login shell in some system (like Linux) we can use ____ command.
a) chshell
b) chshl
c) chsh
d) ch
View Answer

Answer: c
Explanation: 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

Sanfoundry Global Education & Learning Series – Unix.

To practice all areas of Unix, here is complete set of 1000+ Multiple Choice Questions and Answers.

advertisement
advertisement
advertisement
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn