Linux Bash

Linux Bash

In this tutorial, we are going to learn what the shell is? And how many various shells we have, we have also covered most of the bash shell features. We further learn to use the Linux shell in Windows 10, but it has its own limitations.

What is a Shell?

In all the Linux-based operating systems, we have an application or interpreter called the shell. This shell program is used to interpret the commands, execute them, and show the output. Shell has more power on the operating system because the shell is nearer to the Linux kernel.

Types of Shell

There are various types of shells. Some have specific use cases, and some are more robust than others.

Linux Bash

Bourne shell: Bourne shell was developed by Steve Bourne and was the primary shell for the early UNIX. Bourne shell was written at AT and Bell Labs. This shell is labeled as “sh.”

C shell: Bill Joy created this shell at the University of California in 1970. C shell was an alternative to the Bourne shell, and it was programmed in C programming language. This shell is labeled as “csh.”

Korn Shell: David Korn programmed this shell at AT and Bell Labs. The script written for the C shell can be executed in the Korn shell, it is also a lot faster than the C shell. This shell is labeled as “ksh.”

Bourne Again Shell: This shell is the most popular of all the shells available. This shell is denoted as “bash,” and it includes all the Bourne shell and the Korn shell features.

FeaturesBourne shellC shellKorn shellBourne again shell
Platform IndependentYesYesYesYes
Usual EnvironmentUNIXPOSIXPOSIXPOSIX
Command Name CompletionNoYesYes (extendable)Yes
Mouse supportNoNoNoNo
Year of Release1977197819831989
AutocorrectionNoNoNoNo
Command argument completionNoNoNoWhen defined

Features of Bash Shell

Some of the most common features of the bash shell are listed below.

Shell commands: Shell has the power to command the OS with higher priority. Bash shell provides almost all kinds of commands to do several tasks from the terminal. We have commands for creating files “touch,” for text editor “vi,” for creating folder “mkdir,” for removing file and folder “rm,” etc.

I/O Redirection: Input/Output redirection has a special place in the commands. With the help of these symbols, you can redirect the input and output of any command to another command or a file. Angular brackets are used for redirections.

Interactive: The bash shell is interactive in behavior. You could give input and get output on the same screen.

Manuals/help: bash shell has excellent documentation and manuals available for each command. These manuals provide each detail about using the command and give examples of using them with various options.

Scripting: On the shell, only one line of commands can be run at a time. But shell also provides the functionality of running multiple commands at a time. This functionality is achieved by shell scripting.

Functions: These functions provide the ability to run multiple commands for the later execution of them by using the single name of the group. After creating them can be used the same as a command.

Extras: bash shell has some extra features like basic debugging, command-line completion, brace expansion, signal handling, and many more.

Shell Scripting

What is scripting?

To understand what scripting is? First, we must know how the written program runs on the hardware. When you execute the written code in general programming languages, it is first compiled and then executed. But in scripting languages, the program doesn’t need to be compiled. It is just directly interpreted.

What is shell scripting?

Earlier in the tutorial, we understood what a shell is? And just above, we get to know about scripting. So, when the features of scripting languages are executed on the Linux shell, this is known as shell scripting. The commands on the shell are directly interpreted, which is why the shell is also known as an interpreter.

Example of shell scripting

Here we have prepared an example for you to understand the working of the shell scripting. In-depth knowledge on shell scripting will be shared in the following tutorials.

Create a shell script file and write some common commands in the file like the date and cal command.

Linux Bash

Provide the executable permissions to the script file.

Linux Bash

Run the shell script and get output.

Linux Bash

How to Install Linux bash shell on Windows 10?

Yes, the Linux bash shell can be used on windows 10. Microsoft Windows has provided support for Linux, known as “Windows Subsystem for Linux” (WSL). WSL was initially released in 2016, and WSL 2 was released in the year 2019. This application was an additional layer to execute Linux binaries on windows. But before using WSL, you have to enable these features on Microsoft Windows 10. Below given steps should be followed to install and run the WSL.

  1. Enable WSL and VM support
  2. Reboot
  3. Install Ubuntu CLI

Enable WSL and VM support:

To enable the features for “Windows Subsystem for Linux” and “Virtual Machine Support,” you have to press the window key and search “Turn windows features on or off.”

Linux Bash

After opening this, click on the checkboxes for WSL and Virtual Machine. Click ok.

Linux Bash

Reboot

Now reboot the computer.

Install Ubuntu

Open windows store and search for ubuntu and open the highlighted application.

Linux Bash

Now get and install the ubuntu application.

Linux Bash

Run Linux in windows

Search for “ubuntu” in windows search and open it.

Linux Bash
Linux Bash

Now you can use the Linux bash shell inside windows 10. Windows subsystem for Linux also allows you to install all the command-line tools.