SHELL AND ITS TYPES
IN LINUX
Prof. NeerajBhargava
Mrs. Shubha Chaturvedi
Department of Computer Science, School of Engineering & System Science
MDS University Ajmer, Rajasthan
Different Types of Shells
•In UNIX there are two major types of shells:
1.The Bourne shell (includes sh, ksh, and bash)
2.The C shell (includes cshand tcsh)
•IfyouareusingaBourne-typeshell,the
defaultpromptisthe$character.
•IfyouareusingaC-typeshell,thedefault
promptisthe%character.
The different types of Bourne shells as follow:
1.Bourne shell (sh)
2.Kornshell (ksh)
3.Bourne Again shell (bash)
4.POSIX shell (sh)
The different C-type shells follow:
1.C shell (csh)
2.TENEX/TOPS C shell (tcsh)
The Original Bourne Shell
•TheoriginalUNIXshellwaswritteninthemid-1970s
byStephenR.BournewhilehewasatAT&TBellLabs
inNewJersey.
•TheBourneshellwasthefirstshelltoappearon
UNIXsystems,thusitisreferredtoas"theshell.“
•TheBourneshellisusuallyinstalledas/bin/shon
mostversionsofUNIX.Forthisreason,itistheshell
ofchoiceforwritingscriptstouseonseveral
differentversionsofUNIX.
Features of Bourne Shell
Inadditiontobeingacommandinterpreter,the
Bourneshellisapowerfullanguagewitha
programmingsyntaxsimilartothatoftheALGOL
language.FeaturesoftheoriginalBourneshell:
1.Processcontrol
2.Variables
3.Regularexpressions
4.FlowcontrolandLoops
5.Powerfulinputandoutputcontrols
6.Functions
Drawbacks of Bourne shell
DrawbacksoftheoriginalBourneshellisthat
itishardtouseinteractively.
1.Nofilenamecompletion
2.Nocommandhistoryorcommandediting
3.Difficultyinexecutingmultiplebackground
processesorjobs
The C Shell
•BillJoydevelopedtheCshellwhilehewasatthe
UniversityofCaliforniaatBerkeleyintheearly1980s.
•Itwasdesignedtomakeinteractiveuseoftheshell
easierforusers.
•Anotherdesigngoalwastochangethesyntaxofthe
shellfromtheBourneshell'solderALGOLstyletothe
newerCstyle.
•TheClanguagestyleoftheCshellwasintendedasan
improvementbecausetheClanguagewasfamiliarto
theprogrammersworkingonUNIXatBerkeley.
•TheideawasthatashellthatusedClanguagestyle
syntaxwouldbeeasiertowritescriptsinthanashell
thatusedtheALGOLstylesyntax.
Drawbacks of C Shell
The C shell could not be used for much more
than the most trivial scripts. Some of the
major drawbacksare :
1.Weak input and output controls
2.Lack of functions
3.Confusing syntax due to a "lazy" command
interpreter.
Features of C Shell
AlthoughtheCshelldidnotcatchonforscripts,ithasbecome
extremelypopularforinteractiveuse.Somethispopularityfollow:
1.CommandHistory.Youcanrecallcommandsyoupreviouslyexecuted
forre-execution.Youcanalsoeditthecommandbeforeitisre-
executed.
2.Aliases.Youcancreateshortmnemonicnamesforcommands.
AliasesareasimplifiedformoftheBourneshellfunctions.
3.FileNameCompletion.YoucanhavetheCshellautomatically
completeafilenamebyjusttypingafewcharactersofthefile's
name.
4.JobControls.TheCshellenablesyoutoexecutemultipleprocesses
andcontrolthemusingthejobscommand.
TheCshellisusuallyinstalledonmostsystemsas/bin/csh.
TheTENEX/TOPSCshell,tcsh,isanewerversionoftheCshell
thatenablesyoutoscrollthroughthecommandhistoryusingtheup
anddownarrowkeys.
Features ofKorn shell
Features that the Korn shell brings to the
Bourne shell include the following:
•Command history and history substitution
•Command aliases and functions
•File name completion
•Arrays
•Built-in integer arithmetic
There are 3 major versions of kshavailable:
•The Official version (ksh) :The Official version
is available in binary format (no sources).
•The Public Domain version (pdksh):The Public
Domain version is available in both binary and
source format
•The Desktop version (dtksh) :The Desktop
version provides the capability to create and
display Graphical User Interfaces (GUIs) using
kshsyntax.
POSIX shell
•The POSIX shell is another variant of the Korn
shell.
•Currently, the only major vendor shipping the
POSIX shell is Hewlett-Packard.
•In HP-UX 11.0 (Hewlett Packard Unix), the
POSIX shell is installed as /bin/sh. The Bourne
shell is installed as /usr/old/bin/sh.
The Bourne Again Shell
•The Bourne Again shell, bash,was developed as part of the
GNU project and has replaced the Bourne shell, sh, for
GNU-based systems like Linux.
•All major Linux distributions, including Red Hat, Slackware,
and Caldera, ship with bash as their shreplacement.
•Although it includes C shell (cshand tcsh) and Kornshell
(ksh) features, bash retains syntax compatibility with the
Bourne shell, enabling it to run almost all Bourne shell
scripts.
•bash was written by Brian Fox of the Free Software
Foundation and is currently maintained by Chester Ramey
of Case Western Reserve University.
•Because bash is an implementation of the IEEE
POSIX 1003.2/ISO 9945.2 Shell and Tools
specification, it is extremely portable and can
be built on most UNIX systems.
•It has also been ported to QNX, Minix, OS/2,
and Windows 95/NT. Currently, only Linux
ships with the Bourne Again shell. It is
installed as /bin/bash. On most Linux systems,
it is also installed as /bin/sh.
Features of the Bourne Again Shell
•Somefeaturesthatbashincludesinadditionto
thoseoftheKornshellare:
•Namecompletionforvariablenames,usernames,
hostnames,commands,andfilenames
•Spellingcorrectionforpathnamesinthecd
command
•Arraysofunlimitedsize
•Integerarithmeticinanybasebetween2and64