What is a shell?
Simply put, the shell is a program that takes commands from the keyboard and gives them to the operating system to perform. On most Linux systems a program called
sh (which stands for Bourne Shell, an enhanced version of the original Unix shell program,
sh, written by Steve Bourne) acts as the shell program. Besides
sh, there are other shell programs available for Linux systems. These include:
The “Bourne-again shell” or bash for short was created in 1989 by Brian Fox. It is a Unix shell and command language written as a replacement for the Bourne shell. It has been distributed widely as the default login shell for most Linux distributions
“Z shell” or zsh for short, was created in 1990 by Paul Falstad. It is also a Unix shell and command language based on Bourne shell with a large number of improvements, including some features of bash. Zsh also had the ability to be used as a scripting language with the ability to use shell scripts. It currently has very strong community following and support.
Bash vs ZSH
Bash shell is the default shell for Linux and it is released in the replacement of Bourne Shell.
For the most part bash and zsh are almost identical which is a relief. Navigation is the same between the two and the commands remain the same with a slight change in the output.
The main differences between the two are the following
- Auto-Completion – Both support auto completion but Zsh’s tab-completion is more feature rich giving you a list of options that can be then navigated and selected by the arrow keys rather than having to struggle with case or mess with long list of folders with spaces in it.
- Auto-Correction -In Zsh if you mistype a command, spell correction will detect it and ask you if you want to correct it.
- Plugin Support – Zsh offers over 120 plugins and a very active community behind them. Plugins can offer a custom environment.
Which shell am I using?
# echo "$SHELL"
# ps -p $$
# echo $0
If you want to check how many shells are installed in your pc you can check the /etc/shells
# cat /etc/shells
The default shell can be found at /etc/passwd
# cat /etc/passwd | grep root
Depending on the package manager
# sudo apt install zsh -y
If you want to make zsh your default shell use the following command.
# chsh -s $(which zsh) or # chsh -s $(/usr/bin/zsh)
This applies per user so make sure you are running this command as the user you want to change the default shell to.