Olete.in
Articles
Mock Tests
🧪 Shell Scripting MCQ Quiz Hub
Shell Scripting Mcq Question Set 1
Choose a topic to test your knowledge and improve your Shell Scripting skills
1. What is a shell script?
group of commands
a file containing special symbols
a file containing a series of commands
group of functions
2. Shell scripts need to be saved with an extension .sh .
True
False
all of the above
None of the mentioned
3. Shell scripts are executed in a separate child shell process.
True
False
all of the above
None of the mentioned
4. The first line in any shell script begins with a _____
&
!
$
#
5. To run the script, we should make it executable first by using _____
chmod +x
chmod +r
chmod +w
chmod +rwx
6. To spawn a child of our own choice for running the script, we can use ___ command.
ps
pr
sh
$$
7. Which command is used for making the scripts interactive?
ip
input
read
Write (append)
8. read command is shell’s internal tool.
True
False
all of the above
None of the mentioned
9. A single read statement can be used with one or more variables.
True
False
all of the above
None of the mentioned
10. What are positional parameters?
special variables for assigning arguments from the command line
pattern matching parameters
special variables for reading user input
special variables and patterns
11. The first argument is read by the shell into the parameter ___
1$
$3
$$
$1
12. The complete set of positional parameters is stored in ______ as a single string.
$n
$#
$*
$$
13. Which of the following is used for storing the number of positional parameters?
$n
$#
$*
$2
14. Which of the following commands let us perform a set of instructions repeatedly?
for
while
until
for, while, until
15. Which of the following keywords are used in while loop?
do
done
then
do and done
16. until loop operates with a reverse logic as used in while loop.
True
False
all of the above
None of the mentioned
17. Which one of the following is used for looping with a list?
while
until
case
for
18. Which of the following loop statements uses do and done keyword?
for
while
case
for and while
19. Which command is used for changing filename extensions?
chown
rename
basename
rm
20. Which command is used by the shell for manipulating positional parameters?
set
cut
case
paste
21. ____ statement is used for shifting arguments left.
set
shift
cut
paste
22. Which one of the following is an internal command?
cut
expr
set
isMaster
23. Which symbol is used with the set command for command substitution?
–
—
??
_
24. The ____ allows us to read data from the same file containing the script.
>>
<<
!!
—
25. Any command using standard input can take the input from here document.
True
False
all of the above
None of the mentioned
26. Which of the following command doesn’t accept a filename as an argument?
cut
ls
paste
mailx
27. We can use the here document with interactive programs also.
True
False
all of the above
None of the mentioned
28. ____ command is the appropriate way to interrupt a program.
kill
SIGKILL
INT
trap
29. Which of the following option is used with a set for debugging shell scripts?
-a
-x
-d
-e
30. Suppose x =10, then what will be the value of x$x$?
undefined
erroneous
100
x10$
31. Given x=10 then, The given statement is ____
True
False
all of the above
None of the mentioned
32. A shell script stopped running when we change its name. Why?
location of the file changed
we can’t change the name of the script
$0 was used in the script
many possible reasons
33. Where is the exit status of a command stored?
$0
$>
$1
$?
34. Which of the following is false?
here document provides standard input to any script non interactively
read command is used for making scripts interactive
$* stores the number of arguments specified
&& and || are logical operators
35. test statement cannot ______
compare two numbers
compare two strings
compare two files
check a file’s attributes
36. ___ option is used with a test for checking if the file exists and has the size greater than zero.
-f
-r
-e
-s
37. Every time shift command is used, the leftmost variable is lost.
True
False
all of the above
None of the mentioned
38. Shell provides us with an interface to the operating system.
True
False
all of the above
None of the mentioned
39. On a UNIX system, there can be ____ shells running simultaneously.
1
2
many
4
40. There can be multiple kernels on a single UNIX system.
True
FALSE
all of the above
None of the mentioned
41. The prompt issued by the shell is called ______
prompt
command translator
command prompt
command executor
42. In UNIX there are ___ major types of shells.
2
3
4
many
43. What is the default symbol for command prompt in Bourne shell?
$
%
#
@
44. What is the default symbol for command prompt in C shell?
$
%
#
@a = split(/s/, $str).
45. Which one of the following command will display the name of the shell we are working on?
echo shell
echo $
echo $SHELL
echo $$
46. Which shell is the most common and best to use?
Korn shell
POSIX shell
C shell
Bash shell
47. Which command does not terminates unless we log out of the system?
history
shell
echo
login
48. In Shell’s interpretive cycle, the shell first scans for ____ in the entered command.
characters
priority
meta-characters
wildcards
49. Which of the following expression is a correct wildcard pattern if we want an expression in which the last character is not numeric?
*[!0]
*[0-9]
[0-9]
*[!0-9]
50. The shell waits for the command to complete and normally can’t do any work while the command is executing.
True
False
all of the above
None of the mentioned
Submit