Categories
Linux

What is the Default Shell in Linux Called?

An illustrative guide to introduce you to the Shell concept in Linux and the popular BASH shell

A ‘Shell’ is an ‘Interactive Utility’ provided by Linux systems. Whenever we speak of the command line in Linux or Unix environment we are referring to the ‘Shell’. It works as a mid-man between the user and the system which takes input from the user and feeds that input to the system.

Advertisements

The Linux shell provides a way for users to start programs or manage and manipulate any data on the Linux system. The shell facilitates as a medium for the user to interact with the system through commands.

In this picture, we can see that the Shell lies in between the kernel and the utilities (commands)

Command Prompt is the most fundamental and core part of the Shell in Linux and Unix systems. The $ character is the default prompt in most of the Linux distributions and more specifically in the distributions which use Bourne Shell. Command Prompt acts as an interface where you can enter the commands. These commands re then interpreted executed in the kernel. Shell command is the first program to execute when you first launch a terminal window.

In this brief article, you shall learn bout some basic facts about the Shells in Linux and also the question about the default shell in Linux shall be addressed.


Types Of Shell

Advertisements

In Linux, there are two major types of shells- Bourne Shell and C-type shell. Both types of Shell have some advantages and also drawbacks.

Let us see the specifications of both these types in the following sections.

Bourne Shell

Bourne Shell was written by Stephen Bourne at AT&T Bell Labs. Bourne Shell (sh) was the first to be introduced into the Linux systems. You can find this shell installed as /bin/sh on most of the Linux distributions.

Although Bourne Shell was pretty popular and preferred back then but it had some drawbacks. The ability to recall previous commands was missing in this Shell. sh lacked many modern capabilities like aliases and hence made it less effective.

  • Denoted as sh
  • The $ character is the default prompt.

Following are the subcategories of the Bourne Shell.

  • Bourne Shell (sh)
  • Korn Shell (ksh)
  • Bourne Again Shell (bash)
  • POSIX Shell (sh)

C-Type Shells

Advertisements

C-type shell was created using the C-programming language by Bill Joy. C-Shell or ‘csh‘ is seen as an upgrade over the Bourne Shell (sh). csh introduced many new features like command history and aliases which was missing in the Bourne Shell.

  • Denoted as csh
  • The % character is the default prompt.

Although it was an upgrade over the Bourne shell, it had few challenges. Also one prominent issue with csh was that it required the user to have prior knowledge of the C-programming language as it was built on the basis of C-language.

Following are the subcategories of the C-type Shells.

  • C shell (csh)
  • TENEX/TOPS C shell (tcsh)

On the Linux systems, you can find out different shells available on your system using the cat command. The information about the shells is located at the /etc/shells directory. Use the following command to find the details about the shells.

cat /etc/shells

Output:

gaurav@ubuntu:~$ cat /etc/shells # /etc/shells: valid login shells /bin/sh /bin/dash /bin/bash /bin/rbash gaurav@ubuntu:~$

The Default Shell On Linux

Advertisements

To answer the question “Which is the default shell in Linux?”, the most appropriate answer would be the ‘BASH‘ (Bourne Again Shell). BASH is the most popular shell and hence found on most of the Linux distributions as the default shell.

To check your default shell in Linux, you can use the following command.

echo $SHELL

Output:

/bin/bash

This means that the shell currently in use on my system is the BASH shell.

You can check the current version of the BASH in your Linux system using the following command:

bash --version

Features Of BASH Shell

Advertisements

BASH is backwards compatible with the Bourne Shell (sh). BASH includes many prominent features from the Korn Shell (ksh) as well as the C-Shell (csh).

BASH offers many new features that were absent in its predecessors. And that undoubtedly makes the BASH shell an excellent improvement over its predecessors. Many new features like wildcarding, piping, tab-completion are the significant improvements that make BASH a preferred shell as the default for most of the Linux distributions.

Let us look at some notable features of Bash shell.

Command History: This simple command can save your effort to retype a lengthy command. Command History feature recalls the previously entered commands which can be navigated through the terminal by arrow keys.

Command-Line Editing: This feature is newly introduced with BASH. It allows the user to move freely onto the command line from left to right and right to left. This navigation on the terminal may seem normal now but this was a very significant improvement over its predecessors.

Advertisements

Aliases: This is a derived feature from the C-shell. It allows the users to type only the short name or command. The shell then translates this short command to the longer command.

One Dimensional Array: 1-D Arrays in BASH allows easy referencing of data. The manipulation of the lists of the data also becomes possible.

Startup Files: Startup Files are the scripts that Bash reads and executes when it is launched. Each file is assigned for a specific task.

Environment Security: BASH offers you an extraordinary feature of ‘Restricted Mode’. A BASH starting with the name rbash allows the shell to function in the restricted mode.

Due to all these notable features, the bash shell is a widely preferred shell in Linux and Unix-like systems. It is for the very same reason that it is accepted as the default shell for most of the Linux distributions.

Commands available with the BASH shell

Advertisements

BASH shell offers you a plethora of commands to make your work effortless and control all the actions on your system from your command line itself. Following are some of the fundamental commands BASH shell offers on the Linux distributions.

Note: The list of commands available on the BASH shell is NOT limited to only this table. These are some of the fundamental commands used for illustrative purpose.

CommandDescription
rmcommand used to delete a file
cpcommand used to delete a file or directory
touchcommand to create an empty file
mkdircommand to create a new directory
pwdcommand to print the name of the present working directory
cdcommand to change the directory

Conclusion

After looking at all the basic and important features of the BASH shell, we can conclude that BASH shell is the popular shell out of the available options due to its powerful nature, user-friendly features and a huge basket of commands which make the user’s experience effortless. Also, we can safely say that BASH is the default shell on the Linux distributions.