Last Updated: 24.04.2018
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|
Q: What is Unix Shell?
A Unix shell is a command-line interpreter that provides a Unix-like command line user interface.
Q. List some Unix Shells.
Q: When should we use “if” condition (before)?
When running several commands "if" condition meets.
Q: How do I print all arguments submitted on a command line?
echo $@ or echo $*
Q: Which is the best Way To Pretty Print JSON On The Command-Line
It can handle very large JSON structures, including streams.
Q: What command can be used to test if $a greater than 12?
The following command is used:
[ $a -gt 12 ]
Q: What are the advantages and disadvantages of shell scripting?
Advantages of shell scripting:
Disadvantages of shell scripting:
Q: 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.
Q: How to get end line from a file?
Q. In a program, how to get/set an environment variable?
Q. Which command helpful to forward errors to a file?
The command that used for forwarding error to a file is
Q. 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
Q. What Is The Difference Between $* And $@?
Q. 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.
Q. 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.
Q. What is unix shell scripting?
Unix Commands put together into one text file to execute one after the other.
Q. 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.
Q. 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.
Syntax: $ unset mm
Q. List out few unix commands used very often.
Following are the list of basic unix commands one should aware of:
Q. Syntax for ls command.
Syntax: $ ls
Q. Syntax for cd command.
Q. Syntax for mkdir and rmdir.
Q. 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.
Q. 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.
Q. What are Vi Editor modes available?
While working with Vi Editor, different operations we perform are done in different modes.
Q. 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.
Q. What is “$*” in shell scripting?
Arguments list passed in the current process.
Q. What is the command for number of arguments passed in command line arguments?
“$#” is the command.
Q. How can you get the PID of the current process?
“$$” is used.
Q. Command to work with file permissions?
umask is the command to modify file permissions.
Q. 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.
Q. Types of File Permissions.
Q. Command to delete any file?
If we suppose file name as “mindmajix_temp_files.txt”, then
“$rm mindmajix_temp_files.txt” is the command to remove the file.
Q. 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
Get Updates on Tech posts, Interview & Certification questions and training schedules