Shell Scripting Interview Questions
A list of top frequently asked Shell Scripting interview questions and answers are given below.
1) What is shell script?
A shell script is a command containing text file that contains one or more commands.
2) Why is the use of shell script?
It is used by system administrators to issue numbers of commands to accomplish the task. All commands are added together in a text file (shell script) to complete daily routine tasks.
3) What are the advantages of shell scripting?
These are the two main advantages of shell scripting:
4) What are the disadvantages of shell scripting?
Following are the main disadvantages of shell scripting:
5) What are the different types of variables used in shell script?
There are two types of variables used in shell script:
6) What is the syntax of "nested if statement" in shell scripting?
7) What is the use of "$?" sign in shell script?
While writing the shell script, the "$?" sign is used with "if statement" to check whether the previous command is executed successfully or not.
8) What is the use of break command?
The break command is used to escape from a loop in progress.
9) What is GUI scripting?
GUI stands for Graphical User Interface. It is used for controlling a computer and its applications. GUI scripting supports different applications. It mostly depends on the operating system.
10) What are the various stages of a Linux process it passes through?
A Linux process generally passes through four stages:
11) Is it possible to substitute "ls" command in the place of "echo" command?
12) What is the syntax of while loop in shell scripting?
The while loop is used to repeat its block of commands a number of times. It is different from for loop, it iterates until the while condition is no longer true.
13) What is the difference between soft and hard links?
Inode: Each file contains an index number known as "inode" which is comprised of metadata about the associated file.
Hard Link: is the mirror of original linked file. In such case, hard link and original file contains same inode. Hard link remains linked whether original file is removed.
Soft Link: is like shortcut feature of Windows OS. In such case, hard link and original file contains different inode. Soft link will not work correctly if original file is removed.
14) What is the use of "$#" in Shell Scripting?
The $# shows total number of arguments passed to the script.
15) What are the Zombie processes?
Zombie processes are the processes which are died but exit status is not picked by the parent process.
16) What are the 3 standard streams in Linux?
0 - Standard Input
1 - Standard Output
2 - Standard Error