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:
- It facilitates you to develop your own operating system with relevant features best suited for you.
- You can design software applications according to their platform.
4) What are the disadvantages of shell scripting?
Following are the main disadvantages of shell scripting:
- A weak design can destroy the entire process and could prove a costly error.
- If a typing error occurs during the creation then it can delete the entire data as well as partition data.
- Its initial process is slow and improves gradually.
- Portability between different operating system is difficult.
5) What are the different types of variables used in shell script?
There are two types of variables used in shell script:
- System defined variables: These variables are defined or created by operating system itself.
- User defined variables: These variables are defined by system users.
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:
- Waiting: In this stage, the Linux process waits for resource.
- Running: In this stage, the Linux process is currently being executed.
- Stopped: In this stage, the Linux process is stopped after successful execution.
- Zombie: This stage is known as zombie because the process has stopped but still active in process table.
11) Is it possible to substitute "ls" command in the place of "echo" command?
Yes.
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
No comments:
Post a Comment