Latest Shell Scripting Interview Questions and Answers

Read Top Shell Scripting Interview Questions and Answers Experienced, Freshers for Job Interview Quiz with Solutions.

How will you find the total disk space used by a specific user?

du  -s /home/user1             ….where user1 is the user for whom the total disk

space needs to be found.

Write the syntax for “if” conditionals in linux?


If  condition is successful


execute commands


execute commands


What is the significance of $? ?

$? gives the exit status of the last command that was executed.

How do we delete all blank lines in a file?

sed  ‘^ [(backslash)011(backslash)040]*$/d’ file1

where (backslash)011 is octal equivalent of space and

(backslash)040 is octal equivalent of tab

How will I insert a line “ABCDEF” at every 100th line of a file?

sed ‘100iABCDEF’ file1

Write a command sequence to find all the files modified in less than 2 days and print the record count of each.

find . –mtime -2 –exec wc –l {} ;

How can I set the default rwx permission to all users on every file which is created in the current shell?

We can use:

umask 777

This will set default rwx permission for every file which is created to every user.

How can we find the process name from its process id?

We can use “ps –p ProcessId”

What are the four fundamental components of every file system on linux?

bootblock, super block, inode block and  datablock

What is a boot block?

This block contains a small program called “Master Boot record”(MBR) which loads the kernel  during system boot up.

What is a super block?

Super block contains all the information about the file system like size of file system, block size used by it,number of free data blocks and list of free inodes and data blocks.

What is an inode block?

This block contains the inode for every file of the file system along with all the file attributes except its name.

How can I send a mail with a compressed file as an attachment?

zip file1|mailx –s “subject” Recepients email id

 Email content


How do we create command aliases in shell?

alias Aliasname=”Command whose alias is to be created”

What are “c” and “b” permission fields of a file?

“c “ and “b” permission fields are generally associated with a device file. It specifies whether a file is a character special file or a block special file.

What is the use of a shebang line?

Shebang line at top of each script determines the location of the engine which is to be used in order to execute the script.


Popular posts from this blog

TOP Agile Testing Interview Questions and Answers

Latest Agile Testing Interview Questions and Answers

Most Asked ADO.NET Interview Questions and Answers