How to change your default shell on Linux using chsh

Bash isn’t the only Linux shell. It’s easy to try other shells, such as Zsh, which is very popular. When you find one you like, use that chsh Command to make it your default shell. We’ll show you how.

Why a shell is important

the shell sits between you and the operating system. It provides the environment in a terminal window in which you can enter commands and run programs. The shell will check your input and find out what you want. If it can do your commandments on its own, it does so. When outside help is needed, it searches the path and finds the programs that can do whatever you asked for.

There are many different shells available on Linux. They all allow you to perform the same core tasks: exploring the file system, working with files, starting programs, and running scripts. However, they each fulfill these tasks in their own way and have their own peculiarities and peculiarities.

Shells are usually designed by people who want things to behave a certain way. If your thinking is aligned with this designer’s, this bowl might suit you well. It’s also 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, using a different shell can provide a time-saving difference that would have a huge impact on your workflow. You will never know if you are not looking!

What is ZSH and why would you use it instead of Bash?

A bucket full of seashells

We’ve already covered the various Linux shells, but here’s a quick introduction to the most common ones:

  • bash: the Bourne shell is again the standard in many distributions.
  • rabash: this Restricted bash Shell provides minimal functionality to the person or script executing in it.
  • Ash: the Almquist clam is a lighter version of bash.
  • Hyphen: The Debian Alquist Shell is the Standard shell script at Ubuntu. While bash is the standard login and the interactive shell, dash is used to run system processes as it is much lighter than bash.
  • zsch: The Z-shell is a modern version of the bash Family of the clams. It has nice improvements, like command spell checks and suggested fixes.
  • Fish: this friendly interactive shell was written from the ground up and is not derived from any of the other shell families. It should be user-friendly. Among many other benefits, fish offers suggestions for commands based on your history and the contents of the current folder, similar to predictive text.
  • ksh: The KornShell offers a particularly strong scripting language.

What is the difference between bash, zsh and other linux shells?

List of installed shells

Use this command to see what shells are installed on your computer. It simply lists the contents of the /etc/shells File:

cat /etc/shells

We mentioned bash, dash, and rbash, but what is? sh?

sh is the Thompson Shell, written in 1971 by Ken Thompson from Bell Labs Fame. It is no longer maintained and has long been replaced by modern mussels. It’s only included to keep compatibility with older scripts that still have the following as the first line:


This tells the system that the sh Shell to run the script. Do you really have this old shell on your computer and is it being used to run your scripts? the which Command tells us what program is actually running when you enter a command.

Let’s see what’s going on while typing sh:

which sh

This seems to find a binary file. However, if we dig a little deeper, we’ll see that it’s a symbolic link that actually points to dash, the lightweight shell used to run scripts:

ls -l /bin/sh

This is a simple and easy way to provide a safety net for scripts that are expecting to be found sh on modern systems.

Install a different shell

Let’s install that fish Shell and set it as the default for dave. On Ubuntu we enter the following command:

sudo apt-get install fish

Use on Manjaro pacman:

sudo pacman -Sy fish

on Fedora, enter the following:

sudo dnf install fish

When the installation is complete, you can double-check the installed shells:

cat /etc/shells

Our new shell appears as a /usr/bin/fish. Make a note of this path – you will need it shortly.

The environment variable $ SHELL

the $SHELL Environment variable contains the name of your current shell. We can check what setting it is set to echo:

echo $SHELL

Let’s start with that fish Sleeve:


Now let’s look again at what the $SHELL Environment variable says:

echo $SHELL

The first time we use echo $SHELLwhere in the bash Sleeve. The environment variable contains the path to the bash executable, /bin/bash.

When we start that fish Shell we get a friendly welcome message and the prompt changes. What might surprise is this $SHELL Environment still holds the way to bash executable, /bin/bash. That’s fine – that’s normal.

When you start a new shell (or other program), it inherits the environment of the parent shell. So the fish Shell inherits the global and exported environment variables from the bash Sleeve. Since the value is in $SHELL Environment variable was not changed, it has the same value in the fish Shell that has done it in the bash Sleeve.

We run fish like any other program. We can also use exit who leave fish Sleeve. It closes like any other program and we return to bash Sleeve.

This is great for trying new clams, see what they can do and if you can handle them. You can explore before you take the plunge and adopt one as your preferred shell.

If you choose the fish– or some other shell – your default shell, you need that chsh Command.

The chsh command

the chsh The command allows you to change your default shell. The trick is to be aware that you can change both the default login and the default interactive shells. You may want to change one or the other or both.

When you log in to get a command prompt, use the shell that is configured as your login shell. If you are already logged in and open a terminal window, use the shell configured as the interactive shell. These can either be the same or different shells.

To set up your login shell, use chsh without parameters:


You will be asked to enter your password. Then you need to enter the path to the new shell and click on Enter.

If we remotely connect to this test computer from someone else, we are in the fish Shell as soon as we are logged in.

To change your interactive shell, use chsh with the -s (Shell) option. Pass the path to the new shell on the command line:

chsh -s /usr/bin/fish

You will be prompted for your password and will be returned to the prompt for your current shell. You must sign out and sign back in for the change to take effect. When you do, you will see the greeting and that fish Shell prompt.

the $SHELL The environment variable now contains the path to your new standard shell:

echo $SHELL

Change the shell of another user account

If you have and can use root rights sudo, you can change the shells of other user accounts. The command is the same as before, with the addition of that person’s username to the command line:

sudo chsh -s /usr/bin/fish mary

When mary logging in next, she will see 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, this is great! Remember that it must be able to run common scripts such as installation routines. For the shells mentioned here, this shouldn’t be a problem.

Of course, you can also download, install, and test a new shell without making any configuration changes to your computer. When you’re ready to tie the knot, chsh performs the ceremony for you.

Linux commands
Filestar · pv · cat · tac · chmod · grep · difference · sed · With · man · pushed · popd · fsck · Test disk · seq · fd · pandoc · CD · $ PATH · awk · join · jq · wrinkles · unique · journalctl · tail · stat · ls · fstab · echo · fewer · chgrp · chown · Rev · look · Strings · Type · rename · Postal code · unzip · assemble · ummount · To install · fdisk · mkfs · rm · rmdir · rsync · df · gpg · weather · Nano · mkdir · from · ln · Patch · Convert · rclon · Scraps · srm
Processesalias · screen · above · kind · renice · progress · strace · system · tmux · chsh · story · at · Batch · for free · which · dmesg · chfn · User mod · ps · chroot · xargs · tty · pinkie finger · lsof · vmstat · Time out · Wall · Yes sir · kill · sleep · sudo · it is · Time · groupadd · User mod · groups · lshw · switch off · start anew · Stop · switch off · passwd · lscpu · crontab · date · bg · fg
Networkingnetstat · Ring · Trace route · ip · ss · who is · fail2ban · bmon · she · finger · nmap · ftp · curl · wget · who · who am I · w · iptables · ssh-keygen · ufw

Best Linux Laptops for Developers and Enthusiasts

Related Posts