Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Spring Framework | Web Services | BioInformatics | Java Server Faces | Jboss 3.0 tutorial | Hibernate 3.0 | XML
 
 
Hot Web Programming Job

 

Tutorial Categories: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML

[an error occurred while processing this directive]

The Linux Shell

                         

The shell is an advanced way for communicating to the system. It allows the user to handle a system in a flexible way for conversation and taking initiative. It also allows the user for task automation. The term 'shell' originates by its general term name 'shell' of the kernel. It means being an outer layer of  interface between the user and the kernel (the innards of the operating system). 

In Linux, the term shell refers to an operating system shell which provides an interface for users (Command Line Interpreter). CLI (Command Line Interface) is used to access the services of a kernel. Shell is a text based operating system, in which the user can type commands to perform functions such as run programs, open and browse directories and also can be viewed the running process currently. There are many tasks possible in shell which can not be performed in GUI. e.g. moving files within the system folder and deleting files that are typically locked.

The kernel

The kernel is the Central Component usually called 'The Heart' of the system. It  uses the same license as GNU software do but it is not the part of the GNU. It manages the system's resources and communication between hardware and  software components.  It  also ensure that processes and daemons (server processes) are started and stopped at the exact right times. Besides these the kernel performs many other important tasks. Thus we can say that the kernel is the most important file on the system.

Shell Types

Shells are most commonly associated with Unix, or Unix like operating system using the text-based interface. There are some following types of shell:    

* Bourne shell (sh) 
* Almquist shell (ash) 
* Bourne-Again shell (bash) 
* C shell (csh) 
* TENEX C shell (tcsh) 
* Es shell (es) 
* Korn shell (ksh) 
* rc shell (rc) - shell for Plan 9 and Unix 
* scsh (Scheme Shell) 
* Z shell (zsh) 

Bourne shell (sh)

The Bourn shell is the default Unix shell, which works on UNIX systems and in UNIX related environments. It is still in use but  in the very few places now  it is replaced by the Thompson shell, whose whose executable file has the same name, sh. Bourne shell  is a small program with few features. It is the basic shell. It is developed by Steve Borne of  Bell labs in 1977. 

Bourne shell does not have the interactive facilities like modern shell, thus it is not common in use. It also does not  provide easy shell scripts.  So now bash, C shell and Korn shell like modern shells are common in use. 

The Almquist shell (ash)

The Almquist shell (ash) was originally Kenneth Almquist's clone of the SVR4-variant of the Bourne shell; it is a fast, small, POSIX-compatible Unix shell designed to replace the Bourne shell in later BSD distributions. By intention it did not feature line editing or history mechanisms originally, because Almquist felt that such should be moved into the terminal driver. Current variants have emacs and vi modes.

Derivatives of ash are installed as the default shell (/bin/sh) on FreeBSD, NetBSD, and Minix. ash is also fairly popular in embedded Linux systems; its code was incorporated into the BusyBox catch-all executable often employed in this area.

Some Linux distributions, such as Naked Lady, also use a derivative of ash as the default shell, although the Bourne Again Shell is more popular. Ubuntu symlinks /bin/sh to the ash shell for faster script execution, but keeps bash as the default login shell. Debian's version of ash is known as 
Debian Almquist Shell (dash).

The following is extracted from the ash package information from Slackware:

ash (Kenneth Almquist's ash shell)


Bourn-Again shell (bash)

The bash is the GNU project's Bourne-again shell free software, distributed under the terms of the GNU General Public License, version 2. Brian Fox created Bash in 1987. It runs on most Linux system or Unix like operating system as well as on Mac OS X Tiger.

The standard GNU shell, intuitive and flexible. Probably most advisable for beginning users while being at the same time a powerful tool for the advanced and professional user. On Linux, bash is the standard shell for common users. This shell is a so-called superset of the Bourne shell, a set of add-ons and plug-ins. This means that the Bourne Again shell is compatible with the Bourne shell: commands that work in sh, also work in bash. However, the reverse is not always the case. All examples and exercises in this book use bash.

Bash is a Unix shell written for the GNU Project. Its name is an acronym for Bourne-again shell — a pun ("Bourne again" / "born again") on the name of the Bourne shell (sh), an early, important Unix shell written by Stephen Bourne and distributed with Version 7 Unix, circa 1978. bash was created in 1987 by Brian Fox. In 1990, Chet Ramey became the primary maintainer.

Bash is the default shell on most Linux systems as well as on Mac OS X Tiger, and it can be run on most Unix-like operating systems. It has also been ported to Microsoft Windows within the Cygwin POSIX emulation environment for Windows, and to MS-DOS by the DJGPP project.

C shell (csh)

The syntax of this shell resembles that of the C programming language. Sometimes asked for by programmers.
The C shell (csh) is a Unix shell developed by Bill Joy for the BSD Unix system. It was originally derived from the 6th Edition Unix /bin/sh (which was the Thompson shell), the predecessor of the Bourne shell. Its syntax is modeled after the C programming language. The C shell added many feature improvements over the Bourne shell, such as aliases and command history. Today, the original C shell is not in wide use on Unix; it has been superseded by other shells such as the Tenex C shell (tcsh) based on the original C shell code, but adding filename completion and command line editing, comparable with the Korn shell (ksh), and the GNU Bourne-Again shell (bash). An independently-developed and modernized C shell, created by Nicole Hamilton, also survives on Windows in the form of Hamilton C shell.

Turbo C shell (tcsh)

A superset of the common C shell, enhancing user-friendliness and speed.
The turbo shell (tcsh) based on and compatible with the C shell (csh). It is essentially the C shell with (programmable) filename completion, command-line editing, and a few other features.

The 't' in tcsh comes from the T in TENEX, an operating system which inspired Ken Greer, the author of tcsh, with its command-completion feature. Ken Greer worked on tcsh in the late 1970s at the Carnegie Mellon University. Paul Placeway from Ohio State University continued work on it in the 1980s, and since then it has been maintained by numerous people. Wilfredo Sanchez, the former lead engineer of Mac OS X, worked on tcsh in the early 1990s at MIT.

tcsh replaced csh as the default shell on FreeBSD. Early versions of Mac OS X shipped with tcsh as the default shell, but it has since been replaced by bash.

The es shell

The es shell is a Unix shell that uses the a scripting language similar to the rc shell. The goal of the es shell is to provide a fully functional programming language as a Unix shell. The bulk of es' development occurred in the early 1990s.

Es, unlike other modern shells, does not have job control. Patches to provide job control have been offered, but the currently available job control patches for es have memory leak problems.

Korn shell (ksh)

Sometimes appreciated by people with a UNIX background. A superset of the Bourne shell; with standard configuration a nightmare for beginning users.
The Korn shell (ksh) is a Unix shell which was developed by David Korn (AT&T Bell Laboratories) in the early 1980s. It is wholly upwards compatible with the Bourne shell and includes many features of the C shell as well, such as a command history, which was inspired by the requests of Bell Labs users.

The main advantage of ksh over the traditional Unix shell is in its use as a programming language. Since its conception, several features were gradually added, while maintaining strong backwards compatibility with the Bourne shell.

The ksh93 version supports associative arrays and built-in floating point arithmetic. Its advanced scripting functions put it on a par with specialized programming languages such as AWK and Perl.

For interactive use, ksh provides the ability to edit the command line in a WYSIWYG fashion, by hitting the appropriate cursor-up or previous-line key-sequence to recall a previous command, and then edit the command as if the users were in edit line mode. Three modes are available, compatible with vi, emacs and gmacs (ksh93s will add a 4th vim mode).

ksh aims to respect the Shell Language Standard (POSIX 1003.2 "Shell and Utilities Language Committee").
KornShell manual signed by nu metal band KoЯn members David Silveria, Fieldy and Munky.
Enlarge
KornShell manual signed by nu metal band KoЯn members David Silveria, Fieldy and Munky.

Until 2000, Korn Shell remained AT&T's proprietary software. Since then it has been open source, originally under a license peculiar to AT&T but, since the 93q release in early 2005, it has been licensed under the Common Public License. Korn Shell is available as part of the AT&T Software Technology (AST) Open Source Software Collection. As ksh was initially only available through a commercial license from AT&T, a number of free and open source alternatives were created. These include the public domain pdksh, Free Software Foundation's Bourne-Again-Shell bash, and zsh.

Although the ksh93 version added many improvements (associative arrays, floating point arithmetic, a.o.), some vendors still ship their own version of the older ksh88 as /bin/ksh, sometimes with extensions (as of 2005 only Solaris and NCR UNIX (a.k.a. MP-RAS) ship ksh88, all other Unix vendors migrated to ksh93 and even Linux distributions started shipping ksh93) There are also two modified versions of ksh93 which add features for manipulating the graphical user interface: dtksh which is part of CDE and tksh which provides access to the Tk widget toolkit.

SKsh is an AmigaOS version, that offers several Amiga-specific features such as ARexx interoperability.

The MKS Korn shell is another commercial ksh reimplementation. It is (or at least was) included with Microsoft's Services for Unix.

The rc shell 

rc is the command line interface for Version 10 Unix, Plan 9, and Inferno operating systems. It resembles the Bourne shell, but its syntax is somewhat simpler. It was created by Tom Duff, who is better known for an unusual C programming language construct called Duff's device.

A rewrite of rc for Unix-like operating systems by Byron Rakitzis is also available but includes some incompatible changes. A port of the original rc to Unix is part of Plan 9 from User Space

The Sc shell (scsh)

Scsh is a POSIX API layered on top of the Scheme programming language (currently only a Scheme 48 implementation exists, but others are planned) in a manner to make the most of scheme's capability for scripting.

Scsh includes:

* Library support for list, character, and string manipulations;
* Regular expressions manipulation support using scheme regular expressions, a little languages approach to the capabilities;
* Strong networking support;
* High-level support for awk like scripts, integrated into the language as macros;
* Abstractions supporting ptys;
* A shell language, modelled using quasi-quotation.


The z shell

The Z shell (zsh) is a Unix shell that can be used as an interactive login shell and as a powerful command interpreter for shell scripting. Zsh can be thought of as an extended bourne shell with a large number of improvements, including some of the most useful features of bash, ksh, and tcsh.

The first version of zsh was written by Paul Falstad in 1990 when he was a student at Princeton University. The name zsh derives from Zhong Shao, then a teaching assistant at Princeton University. Paul Falstad thought that his login name, "zsh", was a good name for a shell.

Features of note include:
* Programmable command completion that can help the user type both options and arguments for most used commands, with out-of-the-box support for several hundred commands
* Sharing of command history among all running shells
* Extended file globbing allows file specification without needing to run an external program such as "find"
* Improved variable/array handling
* Editing of multi-line commands in a single buffer
* Spelling correction
* Various compatibility modes, e.g. zsh can pretend to be a bourne shell when run as /bin/sh
* Themeable prompts, including the ability to put prompt information on the right side of the screen and have it auto-hide when typing a long command
* Fully customizable

Attesting to the sheer size of this shell is the now famous first sentence of the shell's manual page, which reads "Because zsh contains many features, the zsh manual has been split into a number of sections", and then goes on to list thirteen items.

Changing your shell

First find out which shell you are using from the shells that are available on your system.

* Switch to using another shell
* Changing to another login shell
* Switch to using another shell

You can switch to another shell for the remainder of your login session. To do this enter the shell command name at the system prompt. For example:
ksh
$
This switches you from your current shell to the Korn shell.

Changing to another login shell

To change the shell that you enter whenever you log in to the system use the chsh (change shell) command. Next time you login you will use the new shell.
You must reset any shell and environment variables that you set in your previous shell's startup file. If you do not they will no longer be in effect.
* Example
* Did You Know?
Example of changing the login shell with the chsh command

To change your login shell to the Korn shell (ksh):
chsh
Changing login shell for sarah.
Old shell name: /bin/csh

New shell: ksh

This changes the user's login shell from the C shell (csh) to the Korn shell (ksh).
If you mistype the name of the shell or specify a shell that is not available on your system:
You will be given a list of all the shells that are available on your system.
or
A message similar to the following will be displayed.
name is unacceptable as a new shell

Did You Know?

A quick way to see what shells are available on a your system is to display the file /etc/shells. For example:

cat /etc/shells
/bin/sh
/bin/csh
/usr/local/bin/Tcsh
/usr/local/bin/bash

This file contains the full pathnames for every shell that is available on your system.

What is Shell Script?

A shell script is a program written for Bash. The simplest shell script can be written straight forward through a sequence of Linux commands without adding variables and flow control, but it can do a lot more when these are added in the the script. Shell scripts are similar to DOS batch files (those files that end in .bat), but shell scripts are more powerful and actually easier to create.
Shell scripts are not compiled but interpreted, which means that the shell reads each line and acts on it immediately. 

Normally shells are interactive. It means shell accept command from you (via keyboard) and execute them. But if you use command one by one (sequence of 'n' number of commands) , the you can store this sequence of command to text file and tell the shell to execute this text file instead of entering the commands. This is know as shell script.

Shell script defined as:
"Shell Script is series of command written in plain text file. Shell script is just like batch file is MS-DOS but have more power than the MS-DOS batch file."

A shell script is a script written for the shell, or command interpreter, of an operating system. It is often considered a simple domain-specific programming language. Typical operations performed by shell scripts include file manipulation, program execution, and printing text. Usually, shell script refers to scripts written for a Unix shell, while DOS and Windows command-line scripts are called batch files, but here we discuss properties of both.

Many shell script interpreters double as command-line interface, such as the Unix shell or the MS-DOS COMMAND.COM. Others, such as AppleScript, add scripting capability to computing environments lacking a command-line interface. Other examples of languages primarily intended for shell scripting include DCL and JCL.

Which shell am I using?

If you don't know which shell you are using, either check the line for your account in /etc/passwd or type the command

echo $SHELL The latest of Linux version being used in internet. 
The latest stable version of the Linux kernel is: 2.6.18.3
The latest prepatch for the stable Linux kernel tree is: 2.6.19-rc6
The latest snapshot for the stable Linux kernel tree is: 2.6.19-rc6-git10
The latest 2.4 version of the Linux kernel is: 2.4.33.4
The latest prepatch for the 2.4 Linux kernel tree is: 2.4.34-pre6
The latest 2.2 version of the Linux kernel is: 2.2.26
The latest prepatch for the 2.2 Linux kernel tree is: 2.2.27-rc2
The latest -mm patch to the stable Linux kernels is: 2.6.19-rc6-mm1


                         

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

0 comments so far (
post your own) View All Comments Latest 10 Comments:
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification

Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2007. All rights reserved.