Blog Archive

Theme images by Storman. Powered by Blogger.


Friday, August 5, 2016

Top 10 Shell Scripting Interview Questions And Answers.

Top 10 Shell Scripting Interview Questions And Answers. Latest Shell Scripting Interview Questions And Answers. Most Frequently Asked Shell Scripting Interview Questions For Freshers And Experienced.


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?

Shell Scripting
Shell Scripting
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: How will you find the 99th line of a file using only tail and head command?

tail +99 file1|head -1

9: Print the 10th line without using tail and head command.

sed –n ‘10p’ file1


10:In my bash shell I want my prompt to be of format  ‘$”Present working directory”:”hostname”>  and load a file containing a list of user defined functions as soon as I login , how will you automate this?

In bash shell we can create “.profile”  file which automatically gets invoked as soon as I login and write the following syntax into it.

export PS1=’$ `pwd`:`hostname`>’ .File1 

Here File1 is the file containing the user defined functions and “.” invokes this file in current shell.

0 on: "Top 10 Shell Scripting Interview Questions And Answers."