Beyond BASH: A Guide to 8 Linux Shell Alternatives

Jarret B

Well-Known Member
Staff member
Joined
May 22, 2017
Messages
454
Reaction score
519
Credits
19,511
Previously, I have discussed the fact that Linux is modular. You can replace parts of a Linux Operating System (OS) and make it a specific type to better suit your needs.

The Linux Shell is another modular piece of the OS and is the Command-Line Interpreter (CLI), or Command-Line Interface, to allow commands to be typed by the user to interact with the OS. The CLI is useful for making scripts, lists of commands that are used by the CLI to automate tasks.

Let's look at eight different Linux Shells, but more exist:
  1. BASH (Bourne Again Shell)
  2. ZSH (Z Shell)
  3. KSH (Korn Shell)
  4. TCSH (TENEX C Shell)
  5. DASH (Debian Almquist Shell)
  6. BS (Bourne Shell)
  7. Fish Shell (Friendly Interactive Shell)
  8. C Shell
Before installing any of these and trying them, be sure to perform any package updates that are needed for your system.

BASH (Bourne Again Shell)

The BASH Shell is the most commonly found in Linux systems. You can open a terminal and check to see if the installation includes BASH as well as which BASH version:

Code:
bash --version

You can also run the command 'echo $0' to get the program name of the shell the system is using in Ubuntu. For Fedora, the output also lists the location of the shell command.

NOTE: Keep in mind that the Shell system is a critical package and you need to have a shell installed.

Installation is done:

Code:
sudo apt install bash (Debian)
sudo dnf install bash (Red Hat)

To see a list of Shells that are installed, use:

Code:
cat /etc/shells

On my Ubuntu 24.04 system, Figure 1 shows the output.

Figure 1.JPG

FIGURE 1

You can see that there are four Shells already installed. They are:
  1. bs - Bourne Shell
  2. bash - Bourne Again Shell
  3. rbash - Restricted BASH
  4. dash - Debian Almquist Shell
The 'rbash' Shell is a Restricted Shell that only allows access to specific commands.

Fedora includes TMUX (Terminal Multiplexer).

To change the default shell, you can use the following command, replacing the location and shell name as needed:

Code:
chsh -s /bin/bash

Depending on your system, you may need to reboot.

ZSH (Z Shell)

The Z Shell has more advanced features than BASH. ZSH is default on macOS and Kali Linux.

ZSH has the added ability of syntax highlighting, spell-checking, auto-correction, and plugin support.

To install ZSH on Ubuntu, use:

Code:
sudo apt install zsh

For Fedora, use:

Code:
sudo yum install zsh

After you have installed ZSH, you can start it to configure it by entering a terminal:

Code:
zsh

The first time, you’ll see a screen similar to Figure 2.

Figure 2.JPG

FIGURE 2

You can exit the configuration, you can simply enter 'q'. If you want a blank configuration file, enter '0'. The name of the configuration file is '~/.zshrc'. If you want to go through the configuration, enter '1'.

NOTE: If you want to go through the configuration again and start from scratch, then delete the file '~/.zshrc' and start 'zsh' again.

If you choose '1', then the system shows the next screen, as shown in Figure 3. Here, you can enable or disable specific functions of the Z Shell. Once you are done with configuring the shell, enter 'q' to save the settings and quit.

Figure 3.JPG

FIGURE 3

Once ZSH has started and you get a prompt, the default for Ubuntu is the Hostname. For Fedora, the default is 'User@Hostname'.

You can tell the version of the Z Shell with the command:

Code:
zsh --version

If we list the contents of '/etc/shells', we can see that it lists ZSH. If you want the Z Shell to be the default when you open a terminal, then use the command:

Code:
chsh -s /bin/zsh

Once you change the default shell, you need to logout and then login to make the changes take effect.

Opening a terminal should give you the prompt for ZSH as I covered.

If you enable line completion, you can see that in your Home folder, you can type 'cd D' and then press Tab. You will get a list of folders starting with 'D'. Press Tab again. It will use the first match listed. Tab again and the line changes to the second option on the list. This is different behavior than BASH.

Korn Shell (KSH)

The Korn Shell is default on AIX and OpenBSD. KSH is an advancement of BASH by implementing some features of the C Shell and allows for backwards compatibility of BASH scripts.

To install ZSH on Ubuntu, use:

Code:
sudo apt install ksh

For Fedora, use:

Code:
sudo yum install ksh

After you have installed KSH, you can start it to configure it by entering a terminal:

Code:
ksh

Once installed, you can list the shells and you should see the addition of KSH and RKSH. RKSH is a Restricted Korn Shell that only allows access to certain commands.

To change the default shell in the terminal, use the 'chsh' command and specify the location of KSH as noted in the 'shells' list. Logout and back in to make the changes effective.

NOTE: For Ubuntu, the shell name is 'ksh93'.

Similar to the previous example for ZSH, you can type the command 'cd D', I your Home folder, and press Tab. You should get a numbered listing of the folders that start with 'D'.

TCSH (TENEX C Shell)

TCSH is an advanced version of the C Shell. It includes command-line editing, completion and remains backwards compatible with the C Shell.

To install TCSH on Ubuntu, use:

Code:
sudo apt install tcsh

For Fedora, use:

Code:
sudo yum install tcsh

After you have installed TCSH, you can start to configure it by entering a terminal:

Code:
tcsh

Once you change the shell to TCSH, and logout, then back in, TCSH should run as default.

On Ubuntu, the default prompt is 'Hostname:PWD>'. The system Hostname and Present Working Directory (PWD) makes up the prompt. For Fedora, the prompt is '[USER@Hostname PWD]$'.

Of course, you can change the prompt as you need by setting the system variable for 'PS1'.

DASH (Debian Almquist Shell)

Previously, when looking at the contents of '/etc/shells', you saw that Ubuntu already has DASH installed. This is because DASH is symlinked to '/bin/bash'. BASH is for interaction within the terminal, but you use DASH for system initialization and scripts. The reason the system uses DASH is that it is faster and also POSIX compliant.

For Ubuntu, DASH should not need to be installed, but you can install it, if needed, with:

Code:
sudo apt install dash

For Fedora, you can install DASH with:

Code:
sudo yum install dash

NOTE: On Fedora 41, DASH made it unable for me to log in as the user that had the default shell switched to DASH. I had to log in as another user, then 'sudo su' into the account that failed and change the default shell.

DASH will install and run on Fedora 41, just do not set it to be the default.

BS (Bourne Shell)

Looking at the '/etc/shells' file, you can see that the installation of the Bourne Shell is already done on both Fedora and Ubuntu. This is because BASH is the default and BASH requires BS as its base.

To open a Bourne Shell, just enter 'bs' and you should be in the Bourne Shell.

Fish Shell (Friendly Interactive Shell)

You can use the Fish Shell in Linux or macOS. Keep in mind that Fish is not POSIX compliant. Garuda Linux uses Fish as the default shell.

To install Fish on Ubuntu, use:

Code:
sudo apt install fish

For installing on Fedora, use:

Code:
sudo yum install fish

After you have installed Fish, you can start it to configure it by entering a terminal:

Code:
fish

For both Ubuntu and Fedora, the default prompt for the Fish Shell is 'USER@Hostname PWD>'.

The nice thing about Fish, is that you can see possible completion without using Tab. For instance, when I type 'ls ', it wants to complete it as 'ls -al', as shown in Figure 4.

Figure 4.JPG

FIGURE 4

If I type in 'ls -' and then Tab, Fish will list out the help for possible parameters to use.

Using 'echo $0' does not list 'Fish' as the current shell, but when you start the terminal, the shell informs you it is using Fish and you can enter 'help' to get assistance for using Fish.

C Shell

The C Shell does not have command completion like some other shells. Keep in mind that the C Shell is a basic shell built on by TCSH.

To install the C Shell on Ubuntu, use:

Code:
sudo apt install csh

For Fedora, you can install the C Shell by installing TCSH, which uses CSH as its base. Using CSH as the base is not the case on Ubuntu.

Conclusion

These are just some shells available for Linux systems. Try a few and see if you like any better than your default shell.

Some of these shells have more abilities, but it could take a lot to cover every part of some of them. If needed, use a virtual system to see if there are other shells you may prefer.
 


Follow Linux.org

Members online


Top