Unix Shell Tips: Change Login Shell From Bash to Others

Question: How do I find out what Unix shell I’m currently running? Can you also explain how can I change my Unix shell both temporarily and permanently? (For example, from bash to tsh).

Answer: You can achieve these using $0, exec, chsh -s. In this article, let us review how to do these in detail.


1. What is my current Unix shell?

Use echo $0 command to get your current shell name as shown below.

$ echo $0

2. How to change my current shell to another type – temporarily ?

Use exec command to change your shell temporarily as shown below.

$ echo $0

$ exec /bin/sh

$ echo $0

Note: The above change is temporary. When you relogin, you’ll go back to the original shell.

3. How to change my current shell to another type – permanently ?

To change your shell permanently, use chsh command as shown below.


$ chsh -s /bin/sh

Note: The above change is permanent. Even after relogin, you’ll see only the new shell.

4. How can I find out all available shells in my system ?

All available shells are located in the /etc/shells file.

$ cat /etc/shells
# /etc/shells: valid login shells

For changing your login shell, you can do only from the above output. But for changing the current shell, you can go to any available shell.

5. Installing New Shell

You can install a new shell (for example, ksh) as shown below. After installing new shell, you can use it as your permanent login shell, or temporary shell for your command line operations.

$ sudo apt-get install ksh