What is a Linux shell?

Linux Shell

In this article, we will understand what a shell is and why we need it, and also look at the most commonly used command shells in Linux and Unix.

What is a shell?

Shell (or “shell”“command shell” ) is not only a command interpreter that provides an interface for interaction between the user and the operating system kernel but also a kind of programming language in which there are such constructions as conditional branching operators, loops, variables and much more.

The operating system (OS) launches a command shell for each user when they log in or open a terminal window. The first thing a user sees in a terminal window is a shell prompt – it usually consists of the username and hostname, separated by a character @, followed by the path of the current working directory and one of two characters: $or #.

If the user is not endowed with special rights, then the symbol will be displayed as a prompt to enter commands in the terminal $. If you were logged in as a privileged (root) user, then in the terminal you will see the symbol #:

Linux terminal
Standard user terminal window ($ symbol visible)
Terminal window for a privileged (root) user
Terminal window of a privileged ( root) user (# symbol is visible)

Note: The tilde (~) sign indicates that we are in the current user’s home directory.

After being prompted, the user enters various commands into the terminal, the shell launches programs for the user and then displays the result of their execution in the terminal. Commands can either be entered directly by the user or read from a file called a shell script or shell program.

Below is an example of executing a simple command datethat returns the current date and time:

Date and Time

Internal and external shell commands

The commands entered by the user are divided into two types:

  •    Internal commands are commands that are originally built into the shell.
  •    External commands are commands that are not built into the shell. At their core, they are rather small, separate programs located somewhere in the file system (usually in the /bin or /usr/bin directories).

To determine the type of command, just enter in the terminal windowtype <type_name>:

type of command

As you can see, the team dirspwdcdand true– are internal commands of bash. But the commands unameidand whereis– are external, because they link to the corresponding files in the / usr / bin directory.

For a complete list of internal shell commands, use the command help:

full list of internal shell commands

How do I know which shell I have installed?

If you are just starting with Linux and have not changed your shell, then it is most likely that your system is using bash. The easiest way to find out which shell is currently in use is to refer to the environment variable SHELL:

echo $SHELL

which shell I have installed

In addition, you can use a command psthat returns information about the process with a given identifier. In some cases, the shell identifier is the characters $$:

information about the process with the specified ID

It’s not hard to see that the bash shell is currently being used. To view all available shells on your system, you need to refer to the contents of the etc / shells file :

cat /etc/shells

bash shell is currently being used

Command shell types

On Unix systems, there are two main types of shells called Bourne shell-based shells and C shell-based shells.

Typical Bourne shells are:

  • sh (Bourne shell)
  • bash (Bourne Again shell)
  • ksh (Korn shell)
  • zsh (Z Shell)

Type C Shells include:

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

Top 10 most beautiful dog breeds in the world

Next Article

Top 7 WordPress directory themes

Write a Comment

Leave a Comment

Your email address will not be published. Required fields are marked *