In: Computer Science
What is the purpose of a Shell? How is a Shell used?
The shell is a command-line interface, which means it is purely text-based. The user can type in commands to perform functions such as run programs, open and browse directories, and view processes that are currently running. Since the shell is only one layer above the operating system, you can perform operations that are not always possible using the graphical user interface (GUI). Some examples include moving files within the system folder and deleting files that are typically locked. The catch is, you need to know the correct syntax when typing the commands and you may still be prompted for a password in order to perform administrative functions.
Shells are most commonly associated with Unix, as many Unix users like to interact with the operating system using the text-based interface. Two common Unix shells are the Bourne shell and the C Shell, which is used by BSD. Most Unix systems have both of these shells available to the user. Windows users may be more familiar with DOS, the shell that has long been included with the Windows operating system. Most computer users have no need to use the shell interface, but it can be a fun way to perform functions on your computer.
There are three main uses for the shell:
Interactive use
Customization of your UNIX session
Programming
1. Interactive Use
When the shell is used interactively, the system waits for you to
type a command at the UNIX prompt. Your commands can include
special symbols that let you abbreviate filenames or redirect input
and output.
2. Customization of Your UNIX Session
A UNIX shell defines variables to control the behavior of your UNIX
session. Setting these variables will tell the system, for example,
which directory to use as your home directory, or the file in which
to store your mail. Some variables are preset by the system; you
can define others in start-up files that are read when you log in.
Start-up files can also contain UNIX commands or special shell
commands. These will be executed every time you log in.
3. Programming
UNIX shells provide a set of special (or built-in) commands that
can be used to create programs called shell scripts. In fact, many
built-in commands can be used interactively like UNIX commands, and
UNIX commands are frequently used in shell scripts. Scripts are
useful for executing a series of individual commands. This is
similar to BATCH files in MS-DOS. Scripts can also execute commands
repeatedly (in a loop) or conditionally (if-else), as in many
high-level programming languages.