How To Switch Between Shells In Linux

Today I will be showing you how to switch between the different shells on your system. This includes both temporarily entering a different shell (sub shell) as-well as permanently setting a different shell with the csch command.

How To Find Available Shells

To find a complete list of all the available shells that are already installed on your system, you can read the contents of /etc/shells. Here is an example of both the command being run, as-well as the output.

root@ubuntu:~# cat /etc/shells
# /etc/shells: valid login shells

How To Install New Shells

You can install new shells directly through your package manager. Here are 2 examples of installing zsh, one of the common shells.

sudo apt-get install zsh
sudo yum install zsh

Temporarily Switch Shells

If you just need to temporarily switch shells, for example you are using ksh and need to use bash then you can create a what is called a sub shell inside of your current shell. To do this you simply run the corresponding binary. Here are a few examples.

root@ubuntu:~# bash
root@ubuntu:~# /bin/bash
root@ubuntu:~# sh
root@ubuntu:~# /bin/zsh
root@ubuntu:~# /bin/ksh

Change Default Shell In Linux

If you would like to change your default shell for every subsequent session then you can do so by using the chsh command. Here are a few examples of permanently changing your shell below.

chsh -s /bin/bash
chsh -s /bin/zsh
chsh -s /bin/fish

Commonly Used Linux Shells

There are plenty of available shells to choose from. Here is a list of commonly used Linux shells.

  • Bash
  • Fish
  • Zsh
  • Ksh
  • Csh

I hope this has been a useful post, please don’t forget to like/comment/share. Thanks!

Leave a Reply

Protected with IP Blacklist CloudIP Blacklist Cloud