If you're looking for Unix Shell Scripting Interview Questions for Experienced or Freshers, you are at right place. There are lot of opportunities from many reputed companies in the world. According to research Unix Shell Scripting has a market share of about 17%. So, You still have opportunity to move ahead in your career in Unix Shell Scripting. Mindmajix offers Advanced Unix Shell Scripting Interview Questions 2018 that helps you in cracking your interview & acquire dream career as Unix Shell Scripting Developer.
|Column Names of result obtained by ps -f command in unix|
|PID||ID of the process|
|PPID||Process ID of Parent|
|C||Process's CPU Utilization|
|STIME||Start Time of the Process|
|TTY||Process Terminal Type|
|TIME||Process CPU Time lapsed|
|CMD||To start the process|
1Q) Compare UNIX Shell Scripting with others
|The overall shell scripts are vast (around 280)||Other approaches cannot handle such a vast term|
|There is no need to write complete payroll system||There is often a need of same|
|Dependency on other software tools is less||They need additional help in most of the cases|
2Q) Explain what do you know about the term shell when it comes to scripting? Name a few shells that are commonly used.
Basically it acts as a direct link among the kernel and the user. It is possible for the system to run multiple shells at the same time despite the fact that there is always only one kernel that remains present. Thus, when command is given by the user, shell begins exchanging information with the kernel. The operations are then executed and the information is conveyed to the user.
The shells that are commonly used in the scripting are ksh, bourne,bash, csh
3Q) In Shell scripting, how you will put separate the grep and egrep?
Grep can easily be extended and the same can then be called as egrep. In other words, the egrep is an advanced version of grip. There are some added features in it and i.e. it can easily be considered for additional occurrence of a previous character. This can also be considered when it comes to alternate matching.
4Q) How you will create shortcut in the Linux?
This can be done with the help of links present in the UNIX. For this, basically there are two links which are considered often. They are generally categorized as
1. Soft Link
2. Hard Link
5Q) Tell something about the Super Block in Shell scripting?
It is basically a program that contains all the information regarding a specific file system. It reflects the block size that is used by its associated number, the size of system in terms of data handling and programming. It also provides information regarding the free inodes and the data blocks which are currently associated with the system.
6Q) Is it possible to pass arguments to the scripts when the same in running in the UNIX?
Yes, it is possible and this practice is followed often. It is done to make sure that the system doesn’t have any error while executing he command and the scripts are running smoothly. There are other rea0sons as well for which it can be executed.
7Q) Can you name the important standard streams in the UNIX shell scripting?
These are Standard Input, Standard Output as well as Standard Error
8Q) How can you calculate the overall number of arguments that have been passed to a script? Why it is important?
This can easily be done by a command $#. The same is required to know the overall load on a script. Every limit has a limit on handling the same and users have to check it often to make sure script remains in the running mode and doesn’t get fail.
9Q) How you will treat the quoted arguments as separate ones from the general? Is it possible to treat them in a single string?
This is done through the command
$@. Yes the same is possible and for this, the command
$* can be applied directly.
10Q) In Shell scripting, how you will display the process id of the process executing currently and id of processes that take place recently?
For this, there are actually two dedicated commands which can be executed directly and they are
11Q) Can you tell something about the Zombie Processes in shell scripting?
These are generally defined as the scripts that have completed their life span but are yet to be picked by parent processes associated with them. In the process table, the users can locate the process id of the same despite it remains non functional. In some special cases, it is possible to provide the same id to the next scripts or processes when the functions performed are similar.
12Q) In shell scripting, what is the significance of the Shebang line?
It simply provides information regarding the location where the engine is placed. The engine is the one that execute the script. The Shebang line is present at the top of the script and it can be neglected by the users if they want the same.
13Q) In UNIX shell scripting, what there is a need to connect the system to remote server according to you?
This is done generally when it comes to executing some special commands and the users are free to get this done through various commands. This simply let users to get an additional control or to get some additional support or help. This is actually considered as one of the effective ways for the same. However, this approach is to be secured with an authentication process that can be a simple username and a password.
14Q) What is the function of utilities that come with the open client driver in the shell scripting?
They are useful for connecting the system with a database server simply. The users have no performed this task to accomplish so many tasks that are relevant and important in scripting. Actually, scripting needs a lot of data and information and it are not always possible that the same is kept at a particular location only. The users have to make sure of an error-free outcome in this approach.
15Q) What do you know about the MBR in the shell scripting? How it is useful for the users?
It stands for Master Boot Record and is basically small program whose prime function is to make sure that the kernel is loaded during the system boot set up. It is present in the boot block. It is nothing but the MBR that simply make sure that the users can perform the boot looping tasks accurately and reliably.
16Q) Suppose you execute a command using exec, what will be the status of your current process in the shell?
All the forked processes which are new get overlays when the exec is executed. The command simply gets executed without making any impact on the current process. Also, no new process will be created in this scenario.
17Q) In shell scripting, where you will find the login names of all the users on a system and how they can be printed at the same time?
There is a file
“etc/shadow file which contain all the information related to the users and the same cab ne printed or displayed anytime when the need of same is felt. You have no reasons to worry for this and the command
awk-F can let you print them all in one go.
18Q) In UNIX, what is the primary fundamental component on a file system?
2. Inode Block
3. Data Block
4. Super Block
They remain present with all the file system in UNIX and can be clubbed together in some special cases when the need of same is felt to perform a specific task.
19Q) How can you put separate soft and the hard link in shell scripting?
Well, shell scripting is a powerful approach. The links are used when it comes to creating shortcuts just like Windows. Soft links are those which generally related to the file name and they don’t have any specific location. They can be anywhere on the file system. On the other side, the hard links are related to the node and have a particular location which is fixed in most of the cases. They remain present on the same file system.
20Q) What according to you is the simplest method for copying a file from one system to another?
There are certain utilities with the help of which this can be done easily and without worrying about anything. The users can simply keep up the pace with them when it comes to the same. These utilities are ftp,scp and rsync. It is necessary to specify the hostname before these utilities are considered.
21Q) In Shell scripting, how the user can frequently monitor a log file that is updating?
There is a concept of tailing in the shell scripting that can be applied for this. By using the tail-f filename this can be done. Actually, it will enable users to display the previous 10 lines on the output. The same reflects the part of the file which is updating continuously.
22Q) Is it possible to use a shell script to determine if the directory actually exists or not?
Yes, this is possible and for this, the users are free to simply consider the UNIX test command. The option that is useful in the
–d option. It is not always necessary that the information regarding the existence of a directory is displayed only when the directory is recognized by the system. Information regarding all the directories whether known to the system or not can be displayed with this command. Generally directories are present in the variable
23Q) Tell the procedure of accessing the command line arguments from a script?
It can be done simply by executing the
$ in the system. It will show all the arguments that have already passed from command line to a script. Sometime you need to specify the argument’s numeric position and the users have to make sure that the things are done in a rightful manner.
24Q) Are you familiar with the methods that are useful in debugging a problem related to the shell script?
The answer to this question depends on the skills of a professional. There are various methods and it is not always necessary that all users consider the similar method for problem debugging. Also, it actually depends on the problem itself.
The first method that can help users to formulate the problem is simply inserting some debug statements. This will actually help the pinpoint to know how and where the problem was declared itself or reported. Another method that is also common and the users can make use of it is
25Q) How the break and continue in the system are different from one another in scripting?
When a:Break” is used within a shell scripting loop is considered, it simply terminates the entire loop. On the other side, the “Continue” will make only the current iteration to terminate. However, you can have the loop available with you in the next iteration. These are the two powerful and in fact very useful features when it comes to constructing the shell.
26Q) Why writing the Shell Scripts is important according to you?
Well, this is important due to so many reasons and a few important ones are spotlighted below.
1. When it comes to creating customized commands or creating your own, shell scripting is very useful and powerful
2. There are a lot of tasks that can easily be automated in the process
3. The users are responsible for providing the input and this clearly means there will be no errors in the output
4. It is good enough to be considered for time saving
5. A lot of system administration tasks can be accomplished and can be automated
27Q) Where exactly you can store the Shell programs in the system?
They are stored in a file which is tagged as Sh (Bourne Shell)
28Q) In Shell scripting, how can you say that C Shell is better than Bourne Shell?
29Q) How you will make the soft link inactive in the scripting
The soft links can simply be made inactive in your delete the file and the same doesn’t have any impact on the hard link and i.e. the users can access the file copy.
30Q) Do you need a separate compiler for executing a shell program?
No, the same is not required
31Q) What is Unix Shell?
A Unix shell is a command-line interpreter that provides a Unix-like command line user interface.
32Q) List some Unix Shells.
33Q) When should we use “if” condition (before)?
When running several commands "
if" condition meets.
34Q) How do I print all arguments submitted on a command line?
echo $@ or echo $*
35Q) Which is the best Way To Pretty Print JSON On The Command-Line
It can handle very large JSON structures, including streams.
36Q) What command can be used to test if $a greater than 12?
The following command is used:
[ $a -gt 12 ]
37Q: What are the advantages and disadvantages of shell scripting?
Advantages of shell scripting:
Disadvantages of shell scripting:
38Q) What are the difference between &/&&?
& - "Bitwise AND", evaluates both sides of the operation.
&& - "Logical AND Operator", evaluates at the left side of the operation (If it is True) it continues at the right side.
Check Out Unix Shell Scripting Tutorials
39Q) How to get end line from a file?
40Q) In a program, how to get/set an environment variable?
41Q) Which command helpful to forward errors to a file?
The command that used for forwarding error to a file is
42Q) Which command helps in getting all files on the 3rd place an r, g or i?
Command with on the 3rd place an r, g or i is
43Q) What Is The Difference Between $* And $@?
44Q) Name the Command that used for Displaying the list of files in a directory
$ ls -lrt | grep ^-? command used for displaying the list of files in a directory.
45Q) What is Shell Scripting?
Shell Scripting is collection of commands put together into a file. Script is a command or an instruction given to process and these set of instructions put together in a file to perform some task.
Note: In order to save time from manually providing one instruction at a time to process it, shell scripting is made available that can accept all the commands put together into a file and process them one after the other.
46Q) What is unix shell scripting?
Unix Commands put together into one text file to execute one after the other.
47Q) What are Shell Variables? Mention types of Shell Variables?
Shell variables provide information to execute scripts/commands. There are two types of shell variables: Unix defined and User Defined.
Unix defined variables are by default set by UNIX, to define properties. For example, SHELL is Unix variable that stored information about working shell set to default.
User-defined variables are defined by a developer to store/manage information. For example,
mm = 2018 defined by used means, the value of 2018 is assigned to variable mm.
48Q) Command to wipe out variables defined.
If we consider
$ mm = 2018 as variable defined by the user, then in order to wipe out the variable, the unset command is used.
$ unset mm
49Q) List out few unix commands used very often.
Following are the list of basic unix commands one should aware of:
50Q) Syntax for ls command.
51Q) Syntax for cd command.
1. $ cd - current directory is changed to HOME directory.
2. $ cd mindmajix: current directory is changed to mindmajix directory.
3. $ cd ..: Moves to parent directory of current working directory.
52Q) Syntax for mkdir and rmdir.
1. $ mkdir mindmajix - Creates new folder with name “mindmajix”
2. $ rmdir mindmajix_temp - Removes folder with name “
53Q) Difference between process and thread
To put it in simple words, a thread is a small piece of code/instruction that needs to be executed in a process, whereas a process is a collection of one or more thread executions to complete one complete task.
Note: A process consists of multiple threads can share resources among them as they belong to the same process. And threads belong to different processes cannot share their resources.
54Q) Without restarting the machine, how can we remove all the running processes?
All the running processes in the current shell can be removed using Linux command.
55Q) What are Vi Editor modes available?
While working with Vi Editor, different operations we perform are done in different modes.
56Q) Why do we use “$?” in shell scripting?
This command returns the exit status of the previously executed command.
0 for successful execution, and non-zero for failure.
57Q) What is “
$*” in shell scripting?
Arguments list passed in the current process.
58Q) What is the command for number of arguments passed in command line arguments?
$#” is the command.
59Q) How can you get the PID of the current process?
$$” is used.
60Q) Command to work with file permissions?
umask is the command to modify file permissions.
61Q) Explain structure of File Permissions.
Each permission is assigned with weight to represent in command lines.
In the command line,
Consider below example command for file permissions:
$ chmod 754 mindmajix.txt
Here in 754, each digit indicates permissions for three different people.
62Q) Types of File Permissions.
63Q) Command to delete any file?
If we suppose file name as “
$rm mindmajix_temp_files.txt” is the command to remove the file.
64Q) Command to append output to a file.
>>” is used to append output to file mentioned.
For example, if we want to append Date to today.txt, the following is the command
$ date >> today.txt
Free Demo for Corporate & Online Trainings.