Operating System

What is Unix Shell and What Does It Do?

Unix is an amazing operating system. Isn’t it? You can do so many wonderful things on the command line. But do you...

Written by Deepanshu Gahlaut · 1 min read >

Unix is an amazing operating system. Isn’t it?

You can do so many wonderful things on the command line. But do you know how Unix interpret and process these commands? What lies between you and the Unix system?

The answer is – Shell.

The shell is a process that works as a command interpreter and provides an environment for you to work in, popularly known as the command-line user interface (CLI).

When you login to your Unix system, the shell presents you with the dollar sign ($) prompt which means the shell is ready to accept your commands. It scans or interpret the command and sends it to the kernel for execution. It waits for the command to complete its job and the prompt reappears when the job is done.

unix shell concept

Fig. Unix shell concept

Shell commands are entered by typing text after the $ prompt, for example:

[cmygo@login11 ~]$ pwd
/n/home01/cmygo

The shell command pwd ( print working directory) shows the current location in the filesystem.

Types of Shell

Unix offers a wide variety of shells for you to choose from. These offer similar functionality but each has different capabilities and syntax.

  • Bourne Family, which includes Bourne shell (/bin/sh), Korn shell (/bin/ksh), Bourne-Again shell (/bin/kash) and other modern variants such as Z shell (zsh).
  • C Family, which includes C shell (/bin/csh) and its derivatives such as TENEX C shell (/bin/tcsh).

Simply put, the shell is a process which may be sh, kash, csh etc and the command you enter is actually a standard input to this process. To know which shell you are using, use one of the following commands: echo $0 or echo $shell

Top Shell Features/Responsibilities

  • Wildcarding: This feature carries out commands on a group of files by specifying a pattern to match, rather than specifying an actual file name. For example, the character * is a pattern matching character or wildcard that matches zero or more character(s) in a file (or directory) name.
  • I/O Redirection: It redirects input away from the keyboard and redirects output to a file or device (such as a printer) other than the terminal.
  • Piping: With this feature, you can combine any number of commands together so the standard output of one command becomes the standard input of the next.
  • Variable Substitution: It not only stores data in various user-defined variables but also it has many predefined variables to use.
  • Program Execution: The shell process not only sets up new tasks to run in the background but also make the terminal free for concurrent interactive processing.
  • Aliasing: The shell is responsible for giving an alias name to a command which simply means replacing the word by another string.

The shell is a powerful and interesting Unix/Linux feature that allows people to do complex things with just a few keystrokes.

What are your thoughts on this? Is there something to add? Please share in comments.

References:

  1. https://en.wikipedia.org/wiki/Unix_shell
  2. https://www.ibm.com/support/knowledgecenter/en/ssw_aix_72/shell_feat.htm
Written by Deepanshu Gahlaut
I write on SEO, content marketing, latest technologies, and social media. You can find me online, or at home watching sci-fi movies, listening songs, or sleeping. In addition, my latest obsession is creating, collecting and organizing visual content on my new blog - Infopixi, to help bloggers, marketers, and businesses. Profile

Leave a Reply

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