×

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.


Related Topics

addr2line Command in Linux with Examples

Use of addr2line Command The addr2line command is used to convert addresses to line numbers and file names. This command uses debugging info to check which line number and file name...

4 minutes read.

rename Command in Linux/Unix with Examples

The rename command in Linux is used to rename multiple files at once, using a specified pattern. The command is also known as rename, ren, and mv. This command is...

3 minutes read.

unzip Command in Linux/Unix with Examples

The 'unzip' command in Linux is used to extract files from a ZIP archive file. The command allows you to decompress and extract the files and directories stored in a...

3 minutes read.

man Command in Linux/Unix with Examples

The man command in Linux is used to display the manual pages for a given command or system call. These manual pages provide detailed information on the command's usage, options,...

3 minutes read.

addgroup Command in Linux with Examples

What is the addgroup command? It is a command in Linux to create a new group using specified command lined and the system’s default values. How to add groups Adding a user group:...

4 minutes read.

du Command in Linux/Unix with Examples

The "du" command in Linux (and other Unix-like operating systems) is used to estimate the space used by a file or directory. The du command stands for "disk usage," and...

4 minutes read.

Linux cd

Linux cd: As in GUI operating systems like Windows 10, we use the mouse to travel to various folders back and forth; similarly, we have the “cd” command in Linux...

4 minutes read.

find Command in Linux/Unix with Examples

The find command in Linux is a command-line utility that is used to search for files and directories in a file system. It is a versatile command that can be...

5 minutes read.

tail Command in Linux/Unix with Examples

The "tail" command in Linux (and other Unix-like operating systems) is used to display the last few lines of a file. By default, the tail command will display the last...

4 minutes read.

Linux rmdir command

The default use case of the rmdir command in the Linux system is to delete an empty directory. The below screenshot shows how to delete the empty directory. First, we...

1 minute read.

Rename Folder in Linux

Rename Folder in Linux In the Linux system, there is not any single dedicated command for renaming the files and directories. Mostly, the mv command is used extensively for the purpose...

3 minutes read.

mkdir Command in Linux/Unix with Examples

The "mkdir" command in Linux (and other Unix-like operating systems) is used to create new directories. The "mkdir" command stands for "make directory" and it is used to create a...

3 minutes read.

apt-get Command in Linux with Examples

The apt-get command is a command-line tool that is used to handle packages in Linux. This command handles the processes like retrieving the packages and information from authentic sources for...

5 minutes read.

cd Command in Linux/Unix with Examples

The 'cd' command in Linux is used to change the current working directory. The command stands for "change directory" and it is used to navigate the file system on a...

3 minutes read.

top Command in Linux/Unix with Examples

The 'top' command in Linux is a real-time system monitoring tool that displays information about the running processes and system resource usage. The command provides a dynamic, scrolling view of...

4 minutes read.

touch Command in Linux/Unix with Examples

The "touch" command in Linux (and other Unix-like operating systems) is used to create new empty files or update the timestamps of existing files. The touch command is a simple...

4 minutes read.

wget Command in Linux/Unix with Examples

The wget command is a command-line utility in Linux that is used to download files from the internet. It supports various protocols including HTTP, HTTPS, and FTP and can be...

5 minutes read.

curl Command in Linux/Unix with Examples

The 'curl' command in Linux is a command-line tool that allows you to transfer data from or to a server using various protocols, including HTTP, HTTPS, FTP, and many more....

3 minutes read.

Linux Tutorial for Beginners

What is Linux? Linux is an open source Operating System like Windows, Android, Mac OS, and iOS. An operating system is a software that enables communication between the user and the...

12 minutes read.

cp Command in Linux/Unix with Examples

The cp (copy) command in Linux is a command-line utility that is used to copy files and directories. It is one of the most basic and commonly used commands in...

5 minutes read.