Home arrow Shell Scripting arrow Bash and Bash scripts

Language Translator

Hacking Zone

Hacking Tools
Attacking

Configure Windows

Windows Configuration

Mix Tutorials

Asterisk
Website Building

Novels

Mix Novels

Human Personality

Body Language
Bash and Bash scripts Print E-mail
Article Index
Bash and Bash scripts
Page 2
Page 3
Page 4
Page 5

Bash and Bash scripts

 

In this introduction module we
      ♦ Describe some common shells
      ♦ Point out GNU Bash advantages and features
      ♦ Describe the shell's building blocks
      ♦ Discuss Bash initialization files
      ♦ See how the shell executes commands
      ♦ Look into some simple script examples

1.1. Common shell programs

1.1.1. General shell functions

 

The UNIX shell program interprets user commands, which are either directly entered by the user, or which
can be read from a file called the shell script or shell program. Shell scripts are interpreted, not compiled. The
shell reads commands from the script line per line and searches for those commands on the system (see
Section 1.2), while a compiler converts a program into machine readable form, an executable file − which
may then be used in a shell script.


Apart from passing commands to the kernel, the main task of a shell is providing a user environment, which
can be configured individually using shell resource configuration files.

 

1.1.2. Shell types

Just like people know different languages and dialects, your UNIX system will usually offer a variety of shell
types:
       • sh or Bourne Shell: the original shell still used on UNIX systems and in UNIX−related environments.
         This is the basic shell, a small program with few features. While this is not the standard shell, it is still
         available on every Linux system for compatibility with UNIX programs.
       • bash or Bourne Again shell: 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.
       • csh or C shell: the syntax of this shell resembles that of the C programming language. Sometimes
         asked for by programmers.
       • tcsh or Turbo C shell: a superset of the common C shell, enhancing user−friendliness and speed.
       • ksh or the Korn shell: sometimes appreciated by people with a UNIX background. A superset of the
         Bourne shell; with standard configuration a nightmare for beginning users.


The file /etc/shells gives an overview of known shells on a Linux system:


mia:~> cat /etc/shells
/bin/bash
/bin/sh
/bin/tcsh
/bin/csh


Your default shell is set in the /etc/passwd file, like this line for user mia:


mia:L2NOfqdlPrHwE:504:504:Mia Maya:/home/mia:/bin/bash


To switch from one shell to another, just enter the name of the new shell in the active terminal. The system
finds the directory where the name occurs using the PATH settings, and since a shell is an executable file
(program), the current shell activates it and it gets executed. A new prompt is usually shown, because each
shell has its typical appearance:


mia:~> tcsh

mia@post21 ~]$



 
< Prev
Your Ad Here

RSS socialnet

Add to MyYahoo!
Subscribe in NewsGator Online
Add to Newsburst
Add to Google
Add to My AOL
Add to Pluck
Subscribe in FeedLounge
Add to Windows Live
Add to NetVibes
Subscribe in Rojo
Subscribe in Bloglines
Add to MyMSN
Add to Plusmo for your cellphone
Add to PageFlakes
Add to Technorati
Add to BlinkBits