Find out what your default shell is
May 6, 2021 ‐ 2 min read
In order to see what your default terminal shell is, you can best be in the terminal itself. To see your default shell go into the terminal and type:
$ echo $SHELL /bin/bash
echo command prints out the value of the
$SHELL environment variable. This
$SHELL variable holds the login shell of the current user logged in on the system. On linux systems the preferred shell by a user is stored in the file
See for example this snippet of my
passwd file. As you see the last section of the line is
/bin/bash, the login shell for my user.
$ cat /etc/passwd ... koen:x:1000:1000:,,,:/home/koen:/bin/bash
You may find something odd when it comes to the file path to bash:
/bin/bash. When you use the
which command to find out where a program is located you may see a different path, in my case:
$ which bash /usr/bin/bash
This is due to some legacy reasons. In older systems
bash was located in
/bin. To stay compliant with these older systems
/bin is actually a symlink to
/usr/bin. To validate this you run the command
ls -l /bin and you see in the output
/bin -> usr/bin. This arrow indicates that
/bin is a symlink to
$ ls -l /bin lrwxrwxrwx 1 root root 7 Aug 4 2020 /bin -> usr/bin
Change the default shell
If you prefer to use a different shell than bash you are free to do so. Lets for example change the default shell to zsh. In order to do so you use the command
chsh, short of change shell?
Keep in mind that you don't run this command with
sudo, since you want to change the shell for your current user not for the root user.
If you have
zsh installed you can use it as your default shell with the following command.
$ chsh -s $(which zsh)
In order to have this command take effect you at least need to restart your terminal, and maybe even need to log out first.