Bash is not the only Linux shell. It's easy to try out other shells, like Zsh, which is very popular. If you've found one you like, use the
chsh command to make it your default shell. We'll show you how.
Why a shell is important
The shell is between you and the operating system. It provides the environment in a terminal window that allows you to type commands and run programs. The shell checks your input and determines what you want. If it can make your bids itself, it will. If it needs outside help, it searches the path and finds the programs that can do what you asked.
There are many different shells available on Linux. They all allow you to perform the same core tasks: explore the file system, work with files, launch programs and run scripts. However, they each perform these tasks in their own way and have their own special features and quirks.
Shells are usually designed by people who want things to behave in a specific way. If your thinking matches that of that designer, that scale might suit you well. Moreover, it is easy to try a new shell on Linux.
In most Linux distributions, including Ubuntu, the default shell is
bash . It does a great job and is very capable. However, a different shell can make a time-saving difference that would have a big impact on your workflow. You will never know if you are not looking!
RELATED: What is ZSH and why should you use it instead of Bash?
A bucket of shells
We've covered the different Linux shells before, but here's a quick introduction to the most common:
- bash: The Bourne again shell is the standard in many distributions .
- rbash: This Restricted
bashshell provides minimal functionality for the person or script running in it.
- ash: The Almquist shell is a lighter version of bash.
- dash: The Debian Alquist shell is the default shell script in Ubuntu. While
bashis the default login and interactive shell,
dashis used to run system processes because it is much lighter than
- zsh: The Z-scale is a modern version of the
bashshell family. It offers neat improvements, such as command spelling checks and suggested corrections.
- fish: This friendly interactive shell has been rewritten from scratch and is not derived from any of the other shell families. It is intended to be user-friendly. In addition to its many other benefits, fish offers command suggestions based on your history and the contents of the current directory, similar to predictive text.
- ksh: The KornShell offers a particularly strong scripting language.
RELATED: What's the Difference Between Bash, Zsh, and Other Linux Shells?
View installed shells
Use this command to see which shells are installed on your computer. It simply lists the contents of the file
/ etc / shells :
cat / etc / shells
We already mentioned it
rbash but what is
sh is the Thompson scale, written as early as 1971 by Ken Thompson of Bell Labs fame. It is no longer maintained and has long been replaced by modern shells. It is included purely to maintain compatibility with older scripts that still have the following line:
/ Bin / sh
This instructs the system to use the shell
sh to run the script. Do you really have that ancient shell on your machine and is it used to run your scripts? The
command tells us which program is actually executed when you type a command.
Let's see what happens when you type
This appears to find a binary. if we dig a little deeper we'll see that it is a symbolic link actually referring to
dash the lightweight shell used to run scripts:
ls -l / bin / sh  located in a terminal window. " width="646" height="132" src="/pagespeed_static/1.JiBnMqyl6S.gif" onload="pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);" onerror="this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);"/>
That's a neat, lightweight way to provide a safety net for scripts that expect to find
shon modern systems.
Install Another Shell
Let's install the
fishshell and set it as default for
dave. On Ubuntu we type the following command:sudo apt-get install fish
pacman:sudo pacman -Sy fish
On Fedora, type the following:sudo dnf install fish
When the installation is complete, you can check the installed shells again:cat / etc / shells
Our new shell appears as
/ usr / bin / fish. Write down that path - you will need it soon.
The environment variable $ SHELL
The environment variable
$ SHELLcontains the name of your current shell. We can check which one is set with
echo:echo $ SHELL
Let's start the
. Let's check again what the environment variable
$ SHELLsays:echo $ SHELL
The first time we use
echo $ SHELLwe are in the
bashshell. The environment variable contains the path to the executable
/ bin / bash.
When we launch the scale
fishwe get a friendly welcome message and the command prompt changes. Perhaps surprisingly, the
$ SHELLenvironment still holds the path to the executable
/ bin / bash. That's okay, this is normal.
When you start a new shell (or other program), it inherits the environment from the parent shell. So the
fishshell inherits the global and exported environment variables from the
bashshell. Because the value in the environment variable
$ SHELLhas not changed, it has the same value in the scale
fishas in the scale
fishlike any other program. We can also use
exitto exit the
fishshell. It closes like any other program and we return to the
That's great to try out new shells, see what they can do and if you can handle it. You can explore before making the jump and adopt one as your favorite shell.
If you decide to make the
fish- or some other shell - your default, you have to command the
The chsh command
chshcommand you can change your default shell. The trick is that you are aware that it allows you to change both the default login and the default interactive shells. You can change one or the other or both.
Whenever you log in to get a command prompt, use the shell configured as your login shell. When you are already logged in and open a terminal window, use the shell configured to be your interactive shell. These can be the same or different shells.
chshwithout parameters to set your login shell:chsh
You will be asked for your password. Next, you need to type the path to the new shell and press Enter.
When we connect remotely to this test computer from another, we are in the
fishshell as soon as we log in.
ch to change your interactive shell
-s(shell) option. Pass the path to the new shell on the command line:chsh -s / usr / bin / fish
<img class = "alignnone wp-image-670057 size-full" data-pagespeed-lazy-src = "https://www.howtogeek.com/wp-content/uploads/2020/04/x8-4.png.pagespeed.gp+jp+jw+pj+ws+js+rj+rp+rw+ri+cp + md.ic.dfk5vr8DQ-.png "alt =" chsh -s / usr / bin / fish in a terminal window. "Width =" 646 "height =" 97 "src =" / pagespeed_static / 1.JiBnMqyl6S.gif "onload = "pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon (this);" onerror = "this.onerror = null; pagespeed.lazyLoadImages.loadIfVisibleAndMay40]
You will be asked for your password and you will be returned to the command prompt of your current shell. You must log out and log in again for the change to take effect. When you do that, you see the greeting and the
fishshell command prompt.
The environment variable
$ SHELLnow includes the path to your new default shell:echo $ SHELL 
Change the shell of another user account
If you have root permissions and you can use
sudochange shells of other user accounts gestation is the same as before, adding that person's username to the command line:sudo chsh -s / usr / bin / fish mary
marylogs in next time, she sees the new shell when she opens a terminal window.
Everyone has a favorite
As long as you are comfortable with your choice of shell, and it works for you, that's great! Remember that it must be able to run common scripts, such as installation routines. This should not be a problem for the shells mentioned here.
You can of course also download and install a new shell, and take a test drive without making any configuration changes to your computer. When you are ready to tie the knot,
chshwill perform the ceremony for you.