The GNU Bash is primarily a program that interprets commands entered by the user at the prompt. As we learned in the previous Command line syntax and structure section, each command entered by the user can have three parts:
- The command
- The options (beginning with - or --)
- The arguments
Each word entered in the shell is separated from the others with a space. Commands are the names of various applications installed on our system, where each command has its own options and arguments.
When you want to execute a command entered at the prompt, the Enter key is pressed. After the Enter key is pressed, output from that command is displayed on the shell, which is followed again by the prompt as shown in the following screenshot:
Each command is entered on a single line; however, if you wish you can enter multiple commands on a single line using the semicolon (;), which acts as a command separator.
The various functions performed by the shell include the following:
- It provides an interface between the user and operating system
- It is a way for the user to execute commands and other programs
- It acts as an command-line interpreter for commands entered at the command prompt
- Shell also enables the automation of tasks by reading commands from a special text file, known as a shell script
- Shell provides an environment for users and programs running on the operating system
There are multiple types of shell installed on each Linux distribution, with slight differences in features among them. The Bourne shell (sh) is the most primitive, and the Bash shell is the most advanced. The differences between these shells are listed in the following table:
Feature |
Bourne |
Korn |
C |
Tcsh |
Bash |
Background processing |
Yes |
Yes |
Yes |
Yes |
Yes |
Command history |
No |
Yes |
Yes |
Yes |
Yes |
I/O redirection |
Yes |
Yes |
Yes |
Yes |
Yes |
Shell scripts |
Yes |
Yes |
Yes |
Yes |
Yes |
Command alias |
No |
Yes |
Yes |
Yes |
Yes |
File name completion |
No |
Yes |
No |
Yes |
Yes |
Command completion |
No |
No |
No |
Yes |
Yes |
Command line editing |
No |
Yes |
No |
Yes |
Yes |
Job control |
No |
Yes |
Yes |
Yes |
Yes |