Chun Meng Tan Chun Meng Tan - 2 months ago 21
Linux Question

How to know the default shell process for my terminal?

I am composing a bash script to serve as a utility tools.

The challenges I am facing now is:
- user using my tool will be running in bash environment
- however, some of them might default using krcsh or tcsh. they might have aliases or configurations set in there.

So, I need to prompt/guide user to resolve this during installation. My first challenge: How am I suppose to know the user's default shell within my

Knowing the "default" shell, I can prompt and guide the user to do necessary transfer to bash.

my testing code:

enter image description here

my result:
enter image description here

1/ is fault obviously. It return the current shell which is my (bash)

2/ I am doubtful. It seems to be the history of what I have run before. It does not show me my default configured shell. My case, my terminal default shell is bash, and I run tsch for testing purpose. So the script parsed wrong information and will though my default shell is tcsh. It will then assist me to port configurations from tcsh to bash during the installation process.


If you want to check the shell you are using, you can use the following methods:

  • echo $0 in terminal will show you the program running if you want to check the shell you are currently using.
  • echo $SHELL - with this command you can read the user's default shell in the terminal you are running.

If you want to prompt, easily you can put the echo $SHELL in the part of your script where you need to show the current shell you are using.

Don't forget to put #!/bin/bash if your script is designed to run in a bash shell!