Unix Shell Scripting Interview Questions And Answers

1: What is a shell?

Shell is a interface between user and the kernel. Even though there can be  only one kernel ; a system can have many shell running simultaneously . Whenever  a user enters a command  through keyboard the shell communicates with the kernel  to execute it and then display the output to the user.

2: What are the different types of commonly used shells  on a typical linux system?

csh,ksh,bash,Bourne . The most commonly used and advanced shell used today is “Bash” .

3:What is the equivalent of a file shortcut that we have on window on a Linux system?

Shortcuts are created using “links” on Linux. There are two types of links that can be used namely “soft link” and “hard link”

4:What is the difference between soft and hard links?

Soft links are link to the file name and can reside on different filesytem as well; however hard links are link to the inode of the file and has to be on the same filesytem as that of the file. Deleting the orginal file makes the soft link inactive (broken link) but does not affect the hard link (Hard link will still access a copy of the file)

5: How will you pass and access arguments to a script in Linux?

Arguments can be passed as:

scriptName “Arg1” “Arg2”….”Argn” and can be accessed inside the script as $1 , $2 .. $n

6: What is the significance of $#?

$# shows the count of the arguments passed to the script.

7: What is the difference between $* and $@?

$@ treats each quoted arguments as separate arguments but $* will consider the entire set of positional parameters as a single string.

8: Use sed command to replace the content of the file (emulate tac command)



Then O/p should be


Here G command appends to the pattern space,

h command copies pattern buffer to hold buffer

and d command deletes the current pattern  space.

9: Given a file,  replace all occurrence of word “ABC” with “DEF” from 5th line till end in only those lines that contains word “MNO”

Review Date
Reviewed Item
very useful, Unix shell scripting interview question answers ... thanks for sharing
Author Rating