Searching for jobs know a day has turned out to be very difficult that searching itself becomes a job. Not only preparing for the interview one must know where to apply for appropriate job. Here in Wisdomjobs to avoid such difficulty and save your precious time we have provided a complete details of interview question and answers in our site. To clear the interview, one must prepare well for the interview. There are many leading companies that offer jobs in various position UNIX Shell Scripting, Software Engineer (DataStage, Unix Shell, Java Developer with Unix Shell Scripting, Application/Production Support Engineer, Support Analyst - SQL & Unix + Unix Shell Scripting and many other roles too. To get the complete details about Unix Shell Scripting jobs, Unix Shell Scripting Interview Question and Answers and different kind of roles visit our site www.wisdomjobs.com.
Shell is a command interpreter, which interprets the command which the user gives to the kernel. It can also be defined as an interface between a user and operating system.
Shell scripting is nothing but series or sequence of UNIX commands written in a plain text file. Instead of specifying one job/command at a time, in shell scripting we give a list of UNIX commands like a to-do list in a file to execute it.
The points given below explain the importance of writing shell scripts.
Shell programs are stored in a file called sh.
There are mainly 4 important types of shells that are widely used.
And they include:
The advantages of C Shell over Bourne Shell are:
The crontab file has six fields. The first five fields tell cron when to execute the command: minute(0-59), hour(0-23), day(1-31), month(1-12), and day of the week(0-6, Sunday = 0).
And the sixth field contains the command to be executed
A separate compiler is not required to execute a shell program. The shell itself interprets the command in the shell program and executes them.
There are approximately 280 shell scripts that come with the UNIX operating system.
The basis of shell programming relies on the fact that UNIX shell can accept commands not just only from the keyboard but also from a file.
666 i.e. rw-rw-rw- is the default permission of a file when it is created.
File permissions can be modified using umask.
Any task can be accomplished via shell script at the dollar ($) prompt and vice versa.
Shell variables are the main part of shell programming or scripting. They mainly provide the ability to store and manipulate information within a shell program.
The two types of shell variables are:
1) Unix Defined Variables or System Variables – These are standard or shell defined variables. Generally, they are defined in CAPITAL letters.
Example: SHELL – This is a Unix Defined or System Variable, which defines the name of the default working shell.
2) User Defined Variables – These are defined by users. Generally, they are defined in lower letters
Example: $ a=10 –Here the user has defined a variable called ‘a’ and assigned value to it as 10.
Shell variables are stored as string variables.
Example: $ a=10
In the above statement a=10, the 10 stored in ‘a’ is not treated as a number, but as a string of characters 1 and 0.
The lifespan of a variable inside shell script is only until the end of execution.
Variables can be made unchangeable using readonly. For instance, if we want variable a value to remain as 10 and not to be changed then we can achieve this using readonly.
$ readonly a
Variables can be wiped out or erased using the unset command.
$ a =20
$ unset a
Upon using the above command the variable ‘a’ and its value 20 get erased from shell’s memory.
CAUTION: Be careful while using this unset command.
Positional parameters are the variables defined by a shell. And they are used whenever we need to convey information to the program. And this can be done by specifying arguments at the command line.
There are totally 9 positional parameters present i.e. from $1 to $9.
Example: $ Test Indian IT Industry has grown very much faster
In the above statement, positional parameters are assigned like this.
$0 -> Test (Name of a shell program/script)
$2 -> IT and so on.
A file name which begins with a .(dot) is called as a hidden file. Whenever we try to list the files it will list all the files except hidden file.
But it will be present in the directory. And to list the hidden file we need to use –a option of ls. i.e. $ ls –a.
diff – Basically, it tells about the changes which need to be made to make files identical.
cmp – Basically it compares two files byte by byte and displays the very first mismatch.
New file contains one link. And a new directory contains two links.
The file system is a collection of files which contain related information of the files.
Three different security provisions provided by UNIX for a file or data are:
The three editors are ed, ex & vi.
The three modes of operation of vi editors are:
tput is an alternative command to echo.
Using this, we can control the way in which the output is displayed on the screen.
The number of arguments passed to the script can be found as shown below.
echo $ #
Control Instructions are the ones, which enable us to specify the order in which the various instructions in a program/script are to be executed by the computer. Basically, they determine a flow of control in a program.
There are 4 types of control instructions that are available in a shell:
Sequence Control Instruction – This ensures that the instructions are executed in the same order in which they appear in the program.
Selection or Decision Control Instruction – It allows the computer to take a decision as to which instruction is to be executed next.
Repetition or Loop Control Instruction – It helps a computer to execute a group of statements repeatedly.
Case-Control Instruction – This is used when we need to select from several alternatives.
Loops are the ones, which involve repeating some portion of the program/script either a specified number of times or until a particular condition is being satisfied.
3 methods of loops are:
For loop – This is the most commonly used loop. For loop allows specifying a list of values which the control variable in the loop can take. The loop is then executed for each value mentioned in the list.
While loop – This is used in a program when we want to do something for a fixed number of times. While loop gets executed till it returns a zero value.
Until loop – This is similar to while loop except that the loop executes until the condition is true. Until loop gets executed at least once till it returns a non-zero value.
IFS stands for Internal Field Separator. And it is one of the system variables. By default, its value is space, tab, and a new line.
It signifies that in a line where one field or word ends and another begins.
The break is a keyword and is used whenever we want to jump out of a loop instantly without waiting to get back to the control command.
When the keyword break is encountered inside any loop in the program, control will get passed automatically to the first statement after a loop. A break is generally associated with an if.
Continue is a keyword and is used whenever we want to take the control to the beginning of the loop, by passing the statements inside the loop which have not yet been executed.
When the keyword continue is encountered inside any loop in the program, control automatically passes to the beginning of a loop. Continue is generally associated with an if.
Two files of crontab command are:
cron.allow – It decides which users need to be permitted from using crontab command.
cron.deny – It decides which users need to be prevented from using crontab command.
There are three different commands available to check the disk usage.
And they are:
df – This command is used to check the free disk space.
du – This command is used to check the directory wise disk usage.
dfspace – This command is used to check the free disk space in terms of MB.
Shebang is a # sign followed by an exclamation i.e. !. Generally, this can be seen at the beginning or top of the script/program. Usually, a developer uses this to avoid repetitive work. Shebang mainly determines the location of the engine which is to be used in order to execute the script.
Here ‘#’ symbol is called as hash and ‘!’ is called a bang.
The above line also tells which shell to use.
Unix Shell Scripting Related Tutorials
|Perl Scripting Tutorial||Shell Scripting Tutorial|
|AWK Tutorial||Unix/Linux Tutorial|
|Unix socket Tutorial||Unix makefile Tutorial|
Unix Shell Scripting Related Interview Questions
|Perl Scripting Interview Questions||Shell Scripting Interview Questions|
|Autosys Interview Questions||Unix Inter-Process Communication (IPC) Interview Questions|
|UNIX Memory Management Interview Questions||UNIX Process Management Interview Questions|
|AWK Interview Questions||Unix/Linux Interview Questions|
|Unix socket Interview Questions||Unix Production Support Interview Questions|
All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.