Please enable JavaScript to view the comments powered by Disqus. Top 20 Interview Questions On Shell Scripting In 2020


Top 20 Interview Questions On Shell Scripting In 2020



Last updated 10/06/2021

Top 20 Interview Questions On Shell Scripting In 2020

You have heard of Shell Scripting before, right? 

The shell script is a computer program or command-line interpreter that is specially designed to be run by the Unix shell.

So the best part about writing a shell script is the commands and syntax are exactly similar to those that were directly entered at the command-line. The programmers don’t need to switch to a totally different syntax, like they would have done while working with a different language, or while using a compiled language.

Writing a shell script happens faster than writing an equivalent code in other programming languages. While working on a shell script, you’ll have added advantages like an easy program or file selection, quick start, and interactive debugging. A shell script also helps in providing a sequencing and decision-making linkage around existing programs, and for moderately sized scripts the absence of a compilation step is an advantage.

Now you understand why Shell Scripting is important in the life of a programmer. Hence, it is only obvious that interviewers will love to question you about it. So, what the Interview questions of Shell Scripting might be? Let’s check that out!


1. What is Shell?

The Shell is a Command Line Interpreter that translates commands entered by the user while converting them into a language understandable by the Kernel. The shell interprets a command typed in at the terminal, and calls the program that you want. 

2. What is a Shell Script? Can you name some of its advantages? 

A shell script is a command-containing text-file that contains commands in the order of their execution time. Shell scripts perform several operations like printing text, file manipulation, and program execution.

The two main advantages of shell scripting are:

  • It allows you to develop your own custom OS with relevant features that best suits your needs best.
  • It allows designing software applications according to their respective platforms.

3. What are the different types of variables used in Shell Script?

 A shell script has two types of variables :

  • System-defined variables 
  • User-defined variables 

4. What are the different types of commonly used shells on a typical Linux system?

There are two primary kinds of shells that can be used in a typical Linux system:

  • Bourne Shell
  • C-Shell

5. How do you create a shortcut in Linux?

Creating a shortcut in Linux can be done through the links present in Linux OS:

Hard Link: They are linked to the inode of the file and must be on the same file system as of the file. If you delete the original file, it does not affect the hard link.

Soft Link: They are linked to the file name and can belong to a different file system as well. If you delete the original file, the soft link becomes inactive.

6. Tell us something about the Super Block in Shell scripting?

A SuperBlock is a program that contains a record of specific file systems.

Characteristics of a particular file system like block size, the empty and the filled blocks and their respective counts, the size and location of the inode tables, the disk block map, and usage information, and the size of the block groups can be found in a superblock.

7. What is GUI scripting?

GUI is used to control a computer and its applications. GUI scripting can support different applications and heavily depends on the operating system.

8. What are the various stages of a Linux process it passes through?

A Linux process generally has four stages:

  • Waiting
  • Running
  • Stopped
  • Zombie

9. What is the difference between break and continue commands?

The break is a simple way to escape out of a loop in progress. Break command can be used to exit out from any loop, including while and until loops. 

On the other hand, Continue is responsible for the present iteration of the loop to exit, instead of the entire loop.

10. What is the significance of the Shebang line in Shell Scripting?

The Shebang line is usually found at the top of the script,e.g. #!/bin/sh. This line provides information about the location of the engine. This engine is usually the one executing the script. 

Q11. How to pass an argument to a script?

Arguments are passed through this command:


ct $1

12. How to use arguments in a Script?

Arguments can be used with the help of this command:


cp $1 $2

13. How to calculate the number of passed arguments?

The number of passed arguments can be calculated with this command:


echo "Number of Parameters passed:$#"

14. How to get script name inside a script?

To get a script inside a script, you need to use this command:


echo "Script Name:$0"

15. How to check if the previous command was run successfully?

To check the success of the previous command you need to use this logic:



if var=0

echo "Script was Run successfully"


echo "Script was unsuccessful"


16. How to get the last line from a file using just the terminal?

To get the last line from a file using the terminal, you need to use this command:

tail -1 <filename>

17. How to get the first line from a file using just the terminal?

To get the first line from a file using just the terminal, this following command is used:

head -1 <filename>

18. How to get the 3rd element/column from each line from a file?

To get the 3rd element from each line, we use this command:


awk '{print $3}' $1

19. How to write a function?


function example {

echo "Hello Learner"


20. Write down the Syntax for all the loops in Shell Scripting.

There are three kinds of loops for Shell Scripting- For Loop, Until loop, and While Loop. Their syntaxes are mentioned below:

For Loop:

for var in word1 word2 ... wordN


   Statement(s) to be executed for every word.


While Loop:

while command


   Statement(s) to be executed if the command is true


Until Loop:

until command


   Statement(s) to be executed until command is true



For its user-friendly nature, Shell Scripting is adored across all the industries. Once you are confident about answering these above questions, you’ll have a number of job opportunities handy. Be it a developer, a cloud admin, an AWS architect, Shell Scripting is useful for all the professions. 

Wonder how shell scripting can be applied to the professions mentioned above? Check out our website, apply for the courses suitable for your career choice, and we will teach you all of it!

Topic Related Post

The 10 Most Popular Project Manager Interview Questions For 2021
Top 20 Data Analyst Interview Questions And Answers For 2021
Top 20 Selenium Interview Questions That Are Going To Help You In A Huge Way

About Author

NovelVista Learning Solutions is a professionally managed training organization with specialization in certification courses. The core management team consists of highly qualified professionals with vast industry experience. NovelVista is an Accredited Training Organization (ATO) to conduct all levels of ITIL Courses. We also conduct training on DevOps, AWS Solution Architect associate, Prince2, MSP, CSM, Cloud Computing, Apache Hadoop, Six Sigma, ISO 20000/27000 & Agile Methodologies.



* Your personal details are for internal use only and will remain confidential.


Upcoming Events


Every Weekend


Every Weekend


Every Weekend


Every Weekend

Topic Related

Take Simple Quiz and Get Discount Upto 50%