1. SHELL AND ITS TYPES
IN LINUX
Prof. Neeraj Bhargava
Mrs. Shubha Chaturvedi
Department of Computer Science, School of Engineering & System Science
MDS University Ajmer, Rajasthan
2. Linux Shell
• Computer understand the language of 0's and
1's called binary language.
• In early days of computing, instruction are
provided using binary language, which is
difficult for all of us, to read and write.
• So in O/s there is special program called Shell.
• Shell accepts your instruction or commands in
English and translate it into computers native
binary language.
4. • It's environment provided for user interaction.
• Shell is an command language interpreter
that executes commands read from the
standard input device (keyboard) or from a
file.
• Linux may use one of the following most
popular shells (In MS-DOS, Shell name is
COMMAND.COM which is also used for same
purpose, but it's not as powerful as our Linux
Shells are!)
5. 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 csh and tcsh)
• If you are using a Bourne-type shell, the
default prompt is the $ character.
• If you are using a C-type shell, the default
prompt is the % character.
6. The different types of Bourne shells as follow:
1. Bourne shell (sh)
2. Korn shell (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)
8. • Any of the above shell reads command from user
(via Keyboard or Mouse) and tells Linux O/s what
users want.
• If we are giving commands from keyboard it is
called command line interface ( Usually in-front
of $ prompt. This prompt is depend upon your
shell and environment that you set or by your
System Administrator, therefore you may get
different prompt ).
• NOTE: To find your shell type following
command $ echo $SHELL
9. The Original Bourne Shell
• The original UNIX shell was written in the mid-1970s
by Stephen R. Bourne while he was at AT&T Bell Labs
in New Jersey.
• The Bourne shell was the first shell to appear on
UNIX systems, thus it is referred to as "the shell.“
• The Bourne shell is usually installed as /bin/sh on
most versions of UNIX. For this reason, it is the shell
of choice for writing scripts to use on several
different versions of UNIX.
10. Features of Bourne Shell
In addition to being a command interpreter, the
Bourne shell is a powerful language with a
programming syntax similar to that of the ALGOL
language. Features of the original Bourne shell :
1. Process control
2. Variables
3. Regular expressions
4. Flow control and Loops
5. Powerful input and output controls
6. Functions
11. Drawbacks of Bourne shell
Drawbacks of the original Bourne shell is that
it is hard to use interactively.
1. No file name completion
2. No command history or command editing
3. Difficulty in executing multiple background
processes or jobs
12. The C Shell
• Bill Joy developed the C shell while he was at the
University of California at Berkeley in the early 1980s.
• It was designed to make interactive use of the shell
easier for users.
• Another design goal was to change the syntax of the
shell from the Bourne shell's older ALGOL style to the
newer C style.
• The C language style of the C shell was intended as an
improvement because the C language was familiar to
the programmers working on UNIX at Berkeley.
• The idea was that a shell that used C language style
syntax would be easier to write scripts in than a shell
that used the ALGOL style syntax.
13. Drawbacks of C Shell
The C shell could not be used for much more
than the most trivial scripts. Some of the
major drawbacks are :
1. Weak input and output controls
2. Lack of functions
3. Confusing syntax due to a "lazy" command
interpreter.
14. Features of C Shell
Although the C shell did not catch on for scripts, it has become
extremely popular for interactive use. Some this popularity follow:
1. Command History. You can recall commands you previously executed
for re- execution. You can also edit the command before it is re-
executed.
2. Aliases. You can create short mnemonic names for commands.
Aliases are a simplified form of the Bourne shell functions.
3. File Name Completion. You can have the C shell automatically
complete a filename by just typing a few characters of the file's
name.
4. Job Controls. The C shell enables you to execute multiple processes
and control them using the jobs command.
The C shell is usually installed on most systems as /bin/csh.
The TENEX/TOPS C shell, tcsh, is a newer version of the C shell
that enables you to scroll through the command history using the up
and down arrow keys.
15. Korn shell
• David Korn of AT&T Bell Labs wrote the Korn
shell, ksh, which incorporates all the C shell's
interactive features into the Bourne shell's
syntax.
• In recent years, most vendors have started to
ship the Korn shell with their versions of UNIX.
• Usually you will find it installed as /bin/ksh or
/usr/bin/ksh.
16. Features of Korn 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
17. There are 3 major versions of ksh available:
• 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
ksh syntax.
18. 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.
19. 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 sh replacement.
• Although it includes C shell (csh and tcsh) and Korn shell
(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.
20. • 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.
21. Features of the Bourne Again Shell
• Some features that bash includes in addition to
those of the Korn shell are :
• Name completion for variable names, usernames,
host names, commands, and filenames
• Spelling correction for pathnames in the cd
command
• Arrays of unlimited size
• Integer arithmetic in any base between 2 and 64