JustGeek.in Tech, simplified.

Shells in Linux

If you are using the Linux command line, that means you are using one of the Linux shells to type those commands. Shells are very important in the Unix world.

What exactly is Shell?

You may consider Shell like an interpreter or transponder between the user and the kernel. It allows you to give commands to the kernel and receive the response back from it. Without a shell, you won’t be able to interact with the kernel, run your scripts, or use the features offered by the operating system. A box would be useless without a Shell.

Shell is the core part of the Linux operating system.

Types of Shells

  • sh
  • bash – (the popular guy)
  • ksh
  • csh
  • zsh
  • fish

Explanation of Shells

The Bourne Shell (SH)

SH is considered the first shell, developed by Steve Bourne in AT&T Labs. It was a lightweight and fast shell, which made it popular. Solaris made SH the default shell on their systems.

If you see a $ prompt on your screen, it means you are using SH. Bourne shell is a good read on the Internet.

The Bash Shell

People know him by his name: Bash. It was designed to be compatible with SH. While the backward compatibility was useful, it also had many new features which we still use today. Bash is most popularly used in shell scripting; it supports background tasks and many other improvements from SH.

The birthday bash of /bin/bash is in the year 1984. 🙂

It’s now the default shell in all Linux operating systems.

The Korn Shell

The Korn Shell resides in /bin/ksh. It was built to improve Bourne’s shell and offered new functionalities. It made it easier to run the scripts made for the Bourne shell.

The Z Shell (zsh)

The Z Shell or zsh is a sh shell extension with lots of improvements. If you want a shell that has all the features, then zsh shell is what you should be using.

Here is a small comparison image which I found on Stack Overflow.

How to see what shells are installed on your system?

[centos@centos7 bin]$ cat /etc/shells
/bin/sh
/bin/bash
/usr/bin/sh
/usr/bin/bash
[centos@centos7 bin]$

How to Switch between shells?

To switch between shells, just type the full shell path. For example, if you want to switch to SH, just type /bin/sh.

[centos@centos7 ~]$ /usr/bin/sh
sh-4.2$

How to check what shell you are currently in?

Just type in the command below:

sh-4.2$ ps -p $$
  PID TTY          TIME CMD
  1967 pts/0    00:00:00 sh
sh-4.2$

I hope today you better understand the shells in Linux. Since this is our first page, you may read our about page.