Shell Interview Questions

 
1.
What is a shell?
2.
What are the different types of commonly used shells on a typical linux system?
3.
What is the equivalent of a file shortcut that we have on window on a Linux system?
4.
What is the difference between soft and hard links?
5.
How will you pass and access arguments to a script in Linux?
6.
What is the significance of $#?
7.
What is the difference between $* and $@?
8.
Use sed command to replace the content of the file (emulate tac command)
Eg.
if cat file1

ABCD
EFGH
Then O/p should be
EFGH
ABCD

sed '1! G; h;$!d' file1
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"
10.
Given a file , write a command sequence to find the count of each word.
11.
How will you find the 99th line of a file using only tail and head command?
12.
Print the 10th line without using tail and head command.
13.
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?
14.
Explain about "s" permission bit in a file?
15.
I want to create a directory such that anyone in the group can create a file and access any person's file in it but none should be able to delete a file other than the one created by himself.
16.
How can you find out how long the system has been running?
17.
How can any user find out all information about a specific user like his default shell, real life name, default directory,when and how long he has been using the sytem?
18.
What is the difference between $$ and $!?
19.
What are zombie processes?
20.
How will you copy file from one machine to other?
21.
I want to monitor a continuously updating log file, what command can be used to most efficiently achieve this?
22.
I want to connect to a remote server and execute some commands, how can I achieve this?
23.
I have 2 files and I want to print the records which are common to both.
24.
Write a script to print the first 10 elemenst of Fibonacci series.
25.
How will you connect to a database server from linux?
26.
What are the 3 standard streams in Linux?
27.
I want to read all input to the command from file1 direct all output to file2 and error to file 3, how can I achieve this?
28.
What will happen to my current process when I execute a command using exec?
29.
How will you emulate wc -l using awk?
30.
Given a file find the count of lines containing word "ABC".
31.
What is the difference between grep and egrep?
32.
How will you print the login names of all users on a system?
33.
How to set an array in Linux?
34.
Write down the syntax of "for " loop
35.
How will you find the total disk space used by a specific user?
36.
Write the syntax for "if" conditionals in linux?
37.
What is the significance of $? ?
38.
How do we delete all blank lines in a file?
39.
How will I insert a line "ABCDEF" at every 100th line of a file?
40.
Write a command sequence to find all the files modified in less than 2 days and print the record count of each.
41.
How can I set the default rwx permission to all users on every file which is created in the current shell?
42.
How can we find the process name from its process id?
43.
What are the four fundamental components of every file system on linux?
44.
What is a boot block?
45.
What is a super block?
46.
What is an inode block?
47.
How can I send a mail with a compressed file as an attachment?
48.
How do we create command aliases in shell?
49.
What are "c" and "b" permission fields of a file?
50.
What is the use of a shebang line?