Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

Term paper

Shells for Linux (details of specification of


different old and new shell interfaces of Linux)

From 16/11/2022 to 16/12/2022

SUBMITTED BY:

Name- Rohit Kumar (12219614) Submitted to:


Section – DOC12 Dr. Devender Kumar
Roll No – 54

E-mail:-rohit4love20016@gmail.com

1
Content

ABSTRACT
Keywords
Introduction

History of the Shell

Uses of the Shell


Responsibilities of the Shell
Shells for Linux
Types of Linux Shells
The Shell Interface
Exiting the shell
Environment Variables
Table
Features
Conclusion
Bibliography

2
ABSTRACT
echo read set unset
The purpose of the study is to find the best
shells available in Linux Operating System.
The study has been narrowed down to eight
most prominent shells in use today. With so readonly shift export if
many different Linux distributions and a
plethora of shells, there exists a problem of
plenty, which is rather a good problem to fi else while do
have. Amid all this confusion, one wonders
which shell to use. This is most suitable to
one’s requirement, is modern, up to date and
provides all sorts of features which fulfil the
done for until case
desire of the user as well as the developer.
The article deals in brief about Linux and its
distributions, its philosophy and the freedom esac break continue exit
it provides. Shells, its scripting and shell
types have been explained, one gets an idea
of the study from the introduction. The return trap wait eval
seven Linux shells have been explained in
detail to familiarize the reader with the most
popular and most used shells available. A
clear, concise and comparative analysis of exec ulimit umask
the shells based on their general, interactive,
programming and security features has been
given. Programming features are important
for the developers while a good interface
makes everyone happy. Security features are
a must for anyone who values their privacy
and would like no intrusion in their system Introduction
or their files. The mechanism of
communication is important for I/O Linux comes with several different shells.
handling, as well as managing, interrupts. Although a distribution has a default shell,
The speed of the system is greatly affected users can change to another type or install a
by the level of efficiency of inter-process new one. If you're looking to change your
communication. default shell, knowing the different available
types helps provide a clear overview of the
Keywords possible options.
Keywords are the words whose meaning has
already been explained to the shell.the
keywords cannot be used as variable names
because of it are reserved words with
containing reserved meaning.

3
History of the Shell Responsibilities of the Shell

The first significant, standard UNIX shell The shell is ultimately responsible for
was introduced in V7 (seventh edition of making sure that any commands typed at the
AT&T) UNIX in late 1979, and was named prompt get executed properly. Included in
after its creator, Stephen Bourne. The those responsibilities are:
Bourne shell as a programming language is
based on a language called Algol, and was 1. Reading input and parsing the
primarily used to automate system command line
administration tasks. Although popular for 2. Evaluating special characters, such
its simplicity and speed, it lacks many as wildcards and the history
of the features for interactive use, such as character
history, aliasing, and job control. 3. Setting up pipes, redirection, and
background processing
The C shell, developed at the University of 4. Handling signals
California, Berkeley, in the late 1970s, was 5. Setting up programs for execution
released as part of BSD UNIX. The shell,
written primarily by Bill Joy, offered a number Each of these topics is discussed in detail as
of additional features not provided in the it pertains to a particular shell.
standard Bourne shell. The C shell is based on
the C programming language, and when used as
a programming language, it shares a similar
Shells for Linux
syntax. It also offers enhancements for
A shell is a command-line interpreter
interactive use, such as command-line history,
aliases, and job control. Because the shell was
program that parses and sends commands to
designed on a large machine and a number of the operating system. This program
additional features were added, the C shell has a represents an operating system's interactive
tendency to be slow on small machines and interface and the kernel's outermost layer (or
sluggish even on large machines when compared shell). It allows users and programs to send
with the Bourne shell. signals and expose an operating system's
low-level utilities.
Uses of the Shell
For this exists that shell built-in command
called compgen which most certainly you
When running interactively, one of the did not notice it when you run help -m.
major functions of a shell is to interpret $ compgen -k
commands entered at the command-line if
prompt. The shell parses the command line, then
breaking it into words (called tokens) else
separated by whitespace, which consists of elif
tabs, spaces, or a newline. If the words fi
contain special metacharacters, the shell case
evaluates them. The shell handles file I/O esac
and background processing. After the for
command line has been processed, the shell select
searches for the command and starts its while
execution. until

4
do The terminal program (or terminal emulator)
done enables interaction with the system's
in utilities. When we run any command in the
function terminal, such as ls or cat,, the shell parses,
time evaluates, searches for, and executes the
Coproc corresponding program, if found.
See help -m compgen for more info
about compgen. Types of Linux Shells
1. Bourne Shell (sh)

The Bourne shell was the first default shell


on Unix systems, released in 1979. The shell
program name is sh,, and the traditional
location is /bin/sh. The prompt switches
to $,, while the root prompt is #.

The Bourne shell quickly became popular


because it is compact and fast.
fast
However, sh lacks some standard features,
such as:

Fig.1
 Logicall and arithmetic expansion.
 Command history.
 Other comprehensive features, such
as auto complete.

Modern Unix-likelike systems have


the /bin/sh executable file. The program
does not start the Bourne shell but acts as an
executable file pointing to the default
system shell.

2. C Shell (csh)

The C shell (csh)) is a Linux shell from the


late 1970s whose main objective was to
improve interactive use and mimic the C
language. Since the Linux kernel is
predominantly written in C, the shell aims to
provide stylistic consistency
istency across the
system.

The path to the C shell executable


Fig.2 is /bin/csh.. The prompt uses % for regular
users and # for the root user.

5
New interactive features included:

 History of the previous command. 4.KornShell (ksh)


 User-defined aliases for programs.
 Relative home directory (~). The KornShell (ksh) is a Unix shell and
 Built-in expression grammar. language based on the Bourne shell (sh)
developed in the early 1980s. The location is
The main drawbacks of the C shell are:
in /bin/ksh or /bin/ksh93, while the prompt is
 Syntax inconsistencies. the same as the Bourne shell ($ for a user
 No support for standard input/output and # for root).
(stdio) file handles or functions.
 Not fully recursive, which limits The shell implements features from the C
complex command handling. shell and Bourne shell, aiming to focus on
both interactive commands and
The C shell improved readability and programming features. The KornShell adds
performance compared to the Bourne shell. new features of its own, such as:
The interactive features and innovations in
csh influenced all subsequent Unix shells. 1. Built-in mathematical functions and
floating-point arithmetic.
3. TENEX C Shell (tcsh) 2. Object-oriented programming.
3. Extensibility of built-in commands.
4. Compatible with the Bourne shell.
The TENEX C shell (tcsh) is an extension
of the C shell (csh) merged in the early
The shell is faster than both the C shell and
1980s. The shell is backward compatible
the Bourne shell.
with csh, with additional features and
concepts borrowed from the TENEX OS.
5.Debian Almquist Shell (dash)
The TENEX C shell executable path is
in /bin/tcsh. The user prompt The Debian Almquist Shell (dash) is a
is hostname:directory> while the root Unix shell developed in the late 1990s from
prompt is hostname:directory#. Early the Almquist shell (ash), which was ported
versions of Mac OS and the default root to Debian and renamed.
shell of FreeBSD use tcsh.
Dash is famous for being the default shell
Additional features of the shell include: for Ubuntu and Debian. The shell is minimal
and POSIX compliant, making it convenient
 Advanced command history. for OS startup scripts.
 Programmable autocomplete.
 Wildcard matching. The executable path is /bin/dash, in addition
 Job control. to /bin/sh pointing to /bin/dash on Ubuntu
 Built-in where command. and Debian. The default and root user
prompt is the same as in the Bourne shell.
Since tcsh is an extension of the C shell,
many drawbacks persist in the extended
version.

6
7.Z Shell (zsh).
Dash features include: The Z shell (zsh) is a Unix shell created as
an extension for the Bourne shell in the early
 Execution speeds up to 4x faster than 1990s. The feature-rich shell borrows ideas
bash and other shells. from ksh and tcsh to create a well-built and
 Requires minimal disk space, CPU, usable alternative.
and RAM compared to alternatives.
The executable location is in /bin/zsh. The
The main drawback is that dash is not bash- prompt is user@hostname location % for
compatible. The features not included in regular users and hostname# for the root
dash are known as "bashisms." user. The Z shell is the default shell of Kali
Therefore, bash scripts require additional Linux and Mac OS.
reworkings of bashisms to run succesfully.
Some new features added to the zsh include:
6. Bourne Again Shell (bash)
 Shared history among all running
The Bourne Again shell is a Unix shell and shell sessions.
command language created as an extension  Improved array and variable
of the Bourne shell (sh) in 1989. The shell handling.
program is the default login shell for many  Spelling corrections and command
Linux distributions and earlier versions of name autofill.
macOS.  Various compatibility modes.
 Extensibility through plugins.
The shell name shortens to bash, and the
location is /bin/bash. Like the Bourne shell, The shell is highly configurable and
the bash prompt is $ for a regular user customizable due to the community-driven
and # for root. support through the Oh My Zsh framework.

Bash introduces features not found in the 8. Friendly Interactive Shell (fish)
Bourne shell, some of which include:
The Friendly Interactive Shell (fish) is a
 Brace expansion. Unix shell released in the mid-2000s with a
 Command completion. focus on usability. The feature-rich shell
 Basic debugging and signal does not require additional configuration,
handling. which makes it user-friendly from the start.
 Command history.
 Conditional commands, such as The default executable path is /usr/bin/fish.
the bash if and bash case statements. The user prompt is user@hostname
location>, while the root prompt
is root@hostname location#.

7
Features in the shell include:
[jake@pine tmp]$
 Advanced suggestions/tab
completion based on the current You can change the prompt to display any
directory history. characters you like. You could use as your
 Helpful syntax highlighting and prompt the current directory, the date, the
descriptive error messages. local computer name, or any string of
 Web-based configuration. characters. (To configure your prompt, see
 Command history with search the "Setting your prompt" section later in
options. this chapter.)
Although there are a tremendous number of
The main drawback of fish is non-POSIX
features available with the shell, it's easy to
compliance. However, the developers aim to
begin by just typing a few commands. Try
improve flawed designs from POSIX.
some of the commands shown in the
remainder of this section to become familiar
The Shell Interface with your current shell environment.
 A Terminal window — With the Tip?If, instead of a shell prompt, you see a
desktop GUI running, you can open GUI when you log in, you can still try
a Terminal window (right-click on out the shell commands shown in the
the desktop, then click New next section. To access a shell from the
Terminal) to start a shell. You can GUI, you can open a Terminal window
begin typing commands into the by right-clicking on your desktop and
Terminal window. selecting New Terminal.
If you are using a shell interface, the first
thing you see is the shell prompt. The In the examples that follow, the $ or #
default prompt for a user is simply a dollar symbols indicate a prompt. The prompt is
sign: followed by the command that you type and
then by Enter or Return (depending on your
$ keyboard). The lines that follow show the
output that results from the command.
At this point, list the
The default prompt for the root user is a
contents of your home directory, using
pound sign (also called a hash mark):
the ls command. Either you can type the full
path to your home directory to list its
# contents, or you can use the ls command
without a directory name to list the contents
For most Red Hat Linux systems, the $ or # of the current directory. Using the -a option
prompts are preceded by your user name, to ls enables you to view the hidden files
system name, and current directory name. (dot files) as well as all other files. With
So, for example, a login prompt for the user the -l option, you can see a long, detailed list
named jake on a computer of information on each file. (You can put
named pine with /tmp as the current multiple single-letter options together after a
directory would appear as: single dash, for example, -la.)

8
I just showed a few commands designed to
$ ls -la /home/chris
familiarize you quickly with your Linux
total 158 system. There are hundreds of other
commands that you can try that are
drwxrwxrwx 2 chris sales 1024 May 12 contained in directories such
13:55 .
as /bin and /usr/bin. There are also
drwxr-xr-x 3 root root 1024 May 10 administrative commands
01:49 .. in /sbin or /usr/sbin directories.
-rw------- 1 chris sales 2204 May 18
21:30 .bash_history Environment Variables
 PATH: The list of paths for external
-rw-r--r-- 1 chris sales 24 May 10 01:50 commands.
.bash_logout
SHELL: The type of shell There are few
-rw-r--r-- 1 chris sales 230 May 10 environment variables that are defined for
01:50 .bash_profile the shell. Until now, we understood the
PATH variable. PATH is an environment
-rw-r--r-- 1 chris sales 124 May 10
variable which provides the list of path to be
01:50 .bashrc
searched for external commands. The
drw-r--r-- 1 chris sales 4096 May 10 complete list of environment variables can
01:50 .kde be checked with the help of env command.
-rw-rw-r-- 1 chris sales 149872 May 11
The env command provides the complete list
22:49 letter of environment variables.

Displaying a long list (-l option) of the Some few examples for the environment
contents of your home directory shows you variables of shell are:
more about file sizes and directories.
Directories such as the current directory (.)
and the directory above the current directory  which is currently active.
(..) are noted as directories by the letter "d"  OLDPWD: The last working directory.
at the beginning of each entry. In this case,  PWD: Refers to the Present Working
dot (.) represents /home/chris and two dots Directory.
(..), which is also referred to as the parent  USER: The username for the active
directory, represents /home. shell.
The /home directory is owned by root. All  HOME: The home directory for the
other files are owned by the user chris (who user.
belongs to the sales group).

Exiting the shell


To exit the shell when you are done, either
type exit or press Ctrl+D. If you are exiting
from your login shell (the shell that started
when you first logged in), type logout to
exit the shell.

9
Bill Joy, An Introduction to the C
Shell, UNIX User’s Supplementary
Conclusion Documents, University of California
After reading about several different shell at Berkeley, 1986.
types in this article, you have a better
overview of the available Linux shells. IEEE, IEEE Standard for Information
Other shells exist for specific use cases, and Technology -- Portable Operating
every shell type addresses different System Interface (POSIX) Part 2:
problems. We discussed the definition of
shell. We also seen the philosophy behind Shell and Utilities, 1992.
the shell implementation of the different
types of commands provided by shell and
the environment variables of the shell. We References:
have also gone through few environment
variables. Most importantly, we discussed A PRACTICAL GUIDE TO LINUX
about the PATH variable. We have also seen COMMANDS, EDITORS AND SHELL by
the way to update the PATH and the MARK G. SOBELL, PEARSON
importance of the variable which is
Links:
demonstrated by an example. We learned
the importance of shell and its offerings.  https://en.wikipedia.org/wiki/Unix_s
hell
 https://en.wikipedia.org/wiki/Linux
 https://www.geeksforgeeks.org/differ
Bibliography ent-shells-in-linux/
 https://phoenixnap.com/kb/linux-
Text Books:
shells
A PRACTICAL BEGINNING REDHAT
LINUX 9 by SANDEEP
BHTTACHARAYA, WROX
PROGRAMMER

S. R. Bourne, ‘‘UNIX Time-Sharing


System: The UNIX Shell’’, Bell
System Technical Journal, 57(6),
July-August, 1978, pp. 1971-1990.

Morris Bolsky and David Korn, The


KornShell Command and
Programming Language, Prentice
Hall, 1989.

10

You might also like