Вы находитесь на странице: 1из 3

Shell: The shell is a declarative and parameterized mechanism for executing

common tasks.
What this means is that the shell allows us to execute programs that are generic
enough to take parameters.
For example, by using the file copy program cp, supplying a source file and a
destination file as parameters (also known as arguments), it is possible to copy a
file from one location to another in the file system.
Manage the execution of commands.
It allows users to define shortcuts and abbreviations to refer to these commands
and even to serve as a handy tool for knitting together commands to create
conglomerates that function as new commands (they're called scripts).In terms
of flexibility, performance, task automation, and repetitive processing of tasks,
the shell in the hands of a knowledgeable user still beats a GUI hands down.
Different Types of Shell
The earliest versions of UNIX came with what is today known as the Bourne shell
(also known as sh), named after its inventor, Steve Bourne.
Since then a variety of shell flavours have emerged. However, the core
functionality and basic syntax of all of these shells has changed very little.
The Cshell (or csh), distributed as part of BSD UNIX, was the next popular flavor
of the shell to arrive.
The Cshell syntax resembles the C programming language (particularly when it
comes to writing shell scripts), hence its name.
Other popular shells soon arrived Among them were the Korn shell (or ksh),
which was written by David Korn of AT &T Bell Laboratories, and tcsh or the
Cshell with commandcompletion features that is, the shell intuitively'
completes the commands when we type them in.
The Born Again shell (or Bash) is one of the newer flavors of the shell, and is
almost completely compatible with its ancestor, the Bourne shell.

Builtin Programs and External Programs


There are two different types of command that can be executed from a shell.
They are builtin programs and external programs:
Builtin programs are inherently built into the shell: All shells share a common
set of builtin programs, such as the cd command, which enables us to change
directory
External commands are those that are independent of the flavor of shell. They
can be executed from any shell and yield more or less the same result. For
instance, the date command would output the date no matter what shell it is
executed from.
Of course, when we're working within a particular shell, we can use only the
builtin commands that are valid for that flavor of shell.
If we run a shell script within a particular shell, then it should contain only
commands that are valid for the shell in question. To this end, it is useful to be
able to check whether a given command is a builtin or an external command.
For this, we can use the type command. This command tells us whether it is a
builtin command within the current shell, or (if it is an external program) the
location of the command.
For example, in the Bash shell, if you use type to query the nature of the date
and cd commands, you'll find that the former is external and the latter is
builtin:
$ type date date is /bin/date
$ type cd cd is a shell built-in

File System Commands


File system commands allow us to access and manipulate various parts of the
Unix file system tree. In Unix, the file system is organized as a tree structure, in
much the same way as in other operating systems (each directory can contain
files and subdirectories). For each machine, there is always one root directory;

this is the topmost directory, and contains subdirectories and files. We refer to
the root directory by using the forward slash (/).From this basic structure, there
are a number of tasks that we may need to do, such as changing the working
directory, establishing the contents of a particular directory, or creating, copying,
moving, and deleting files and directories.

Changing and Establishing the Working Directory


The working directory is the directory we're currently working in.
To change the working directory (that is, to select a particular directory to be the
working directory), we use the cd (change directory) command.
For example, to select the root directory to be the working directory, we would
type the following:
$ cd /
To select the directory /home/deepakt (the home directory of the user deepakt)
to be the working directory, we could type this:
$ cd /home/deepakt
Absolute and Relative Paths
In both of the above examples, we've specified the absolute path of the directory
in question. We can also use relative paths. For example, if we wanted to change
the working directory from /home/deepakt to its parent directory, /home,
We could use the absolute path like this:
$ cd /home
or
the relative path, like this:
$ cd ..

Вам также может понравиться