Linux Shell
Linux Shell
The shell can be defined as a command interpreter within an operating system like Linux/GNU or
Unix. It is a program that runs other programs. The shell facilitates every user of the computer as
an interface to the Unix/GNU Linux system. Hence, the user can execute different tools/utilities or
commands with a few input data.
The shell sends the result to the user over the screen when it has completed running a program
which is the common output device. That's why it is known as "command interpreter".
The shell is not just a command interpreter. Also, the shell is a programming language with
complete constructs of a programming language such as functions, variables, loops, conditional
execution, and many others.
For this reason, GNU/Unix Linux Shell is stronger than the Windows shell.
Broadly, the shell is categorized into two main categories which are explained below:
Graphical Shells
These shells specifies the manipulation of programs that are based on the graphical user
interface (GUI) by permitting for operations like moving, closing, resizing, and opening windows
and switching focus among windows as well. Ubuntu OS or Windows OS could be examined as a
good example that offers a graphical user interface to the user to interact with the program.
Various users don't need for typing in any command for all the actions.
⇧ SCROLL TO TOP
Command-line Shell
Various shells could be accessed with the help of a command-line interface by users. A unique
program known as Command prompt in Windows or Terminal in macOS/Linux is offered for
typing in the human-understandable commands like "ls", "cat", etc and after that, it is being run.
The result is further shown to the user on the terminal.
Bash Shell
In the bash shell, bash means Bourne Again Shell. It is a default shell over several distributions of
Linux today. It is a sh-compatible shell. It could be installed over Windows OS. It facilitates
practical improvements on sh for interactive and programming use which contains:
Job Control
Command-line editing
⇧ SCROLL TO TOP
Unlimited size command history
Integer arithmetic in a base from 2-64
Csh/Tcsh Shell
Tcsh is an upgraded C shell. This shell can be used as a shell script command processor and
interactive login shell.
C like syntax
Command-line editor
Job control
Spelling correction
Ksh Shell
Ksh means for Korn shell. It was developed and designed by David G. Korn. Ksh shell is a high-
level, powerful, and complete programming language and it is a reciprocal command language as
well just like various other GNU/Unix Linux shells. The usage and syntax of the C shell are very
same as the C programming language.
Zsh Shell
Zsh shell is developed to be reciprocal and it combines various aspects of other GNU/Unix Linux
shells like ksh, tcsh, and bash. Also, the POSIX shell standard specifications were based on the
Korn shell.
Also, it is a strong scripting language like other available shells. Some of its unique features are
listed as follows:
Startup files
Filename generation
Login/Logout watching
Concept index
Closing comments
⇧ SCROLL TO TOP
Variable index
Key index
Function index and various others that we could find out within the man pages.
All these shells do a similar job but take different commands and facilitate distinct built-in
functions.
Fish
Fish stands for "friendly interactive shell". It was produced in 2005. Fish shell was developed to
be fully user-friendly and interactive just like other shells. It contains some good features which
are mentioned below:
Web-based configuration
Auto-suggestions
Shell Prompt
It is known as a command prompt and it is issued via the shell. We can type any command while
the prompt is shown.
Shell reads our input after we click Enter. It illustrates the command we want to be run by seeing
at the initial word of our input. A word can be defined as the character's unbroken set. Tabs and
spaces separate words.
The below is a common data command example that shows the current time and date:
We can also customize our command prompt with the help of PS1 (environment variable).
Shell Scripting
The common concept of the shell script is the command list. A good shell script will contain
comments which are preceded via # simbol.
Shell functions and scripts are interpreted. It means they aren't compiled.
⇧ SCROLL TO TOP
There are also conditional tests like value Y is greater than value Z, loops permitting us to proceed
by massive data amounts, files to store and read data, and variables to store and read data, and
these scripts may contain functions.
The shells are usually interactive which means they receive commands as input through the users
and run them. Although sometimes we routinely wish to run a set of commands, hence, we have
to type within the commands all-time inside the terminal.
A shell script includes syntax similarly to other programming languages. When we have prior
experience along with a programming language such as C/C++, Python, etc. It will be very easy to
begin with it. The shell script combines the below components:
Functions
The syntax and command are exactly similar to those entered directly in a command line.
Thus, the programmers don't have to switch to completely different syntax
Interactive debugging
Quick start
⇧Shell Script
SCROLL Disadvantages
TO TOP
A single error can modify the command which could be harmful, so prone to very costly
errors.
Script Example
Assume we make a test.sh script. We have to alert a system that the shell script is started before
we include anything else in our script.
For example:
#!/bin/sh
It shows the system that several commands that pursue are to be run by the Bourne shell. It is
known as the shebang due to the symbol # is known as hash and the symbol ! It is known as the
bang.
To make a script including these commands, we put the shebang construct line first, and after
that add any command:
#!/bin/bash
pwd
Comments in shell
We can put our comments in our script below:
#!/bin/bash
⇧ SCROLL TO TOP
Make the script runnable and save the content mention above:
$chmod +x test.sh
$./test.sh
/home/amrood
index.htm unix-
b i tiliti ht
Note:- For executing a program present in the latest directory, we can use the ./program_name
After all, the shell is an actual programming language that is complete with control structures,
variables, and so on. Still, it is only the commands list executed sequentially no matter how
complex a script gets.
The following script is using the read command that gets the input through the keyboard and
appoints it as the variable PERSON value and prints it over STDOUT finally.
← Prev
Next →
Youtube
For Videos Join Our Youtube Channel: Join Now
Feedback
⇧ SCROLL TO TOP