Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Let's say, I opened a terminal and entered / executed some shell commands.

But I didn't invoke explicitly Bash or any other shell.

What shell was used by default?

share|improve this question

4 Answers 4

The one specified on your line in /etc/passwd (it is a : separated line and the shell is the final one).

For example mine:


Here it is /bin/bash (the Ubuntu default)

You can also use chsh:

$ chsh
Changing the login shell for chris
Enter the new value, or press ENTER for the default
        Login Shell [/bin/bash]:

This is telling me my shell is /bin/bash and letting me change it.

Finally, echo $SHELL will do the same:

$ echo $SHELL
share|improve this answer
if it's bash, why is it sometimes invoked explicitly like sudo bash -c "netstat -an | grep LISTEN | grep -v ^unix" ?? – DrStrangeLove Dec 14 '11 at 23:25
I think that's a bad command personally - none of that even requires root. If it did, it would be better written as sudo netstat -an | grep LISTEN | grep -v ^unix. I see no reason to enclose that in a bash subshell. – Caesium Dec 14 '11 at 23:30
@DrStrangeLove: If more than one command in the pipe needed root permissions, then sudo bash -c "..." would ensure that the entire pipe is executed by root. – Keith Thompson Dec 15 '11 at 0:51
If you don't know which commands require root (and why), you shouldn't run them. Otherwise, why trust any command/program/script any more than is required. If you can't commandA | sudo commandB | commandC, you could do a sudo id first (runs the id command as root, but also acquires a "use sudo without password prompt" token that lasts for (default) 15 minutes. – waltinator Dec 20 '11 at 4:10
If you use chsh then you must log out and log back in to see this change. – Neil Traft Jul 6 '14 at 22:01

By default it's bash:

env | grep SHELL


share|improve this answer
Not necessarily. If you create a new user with useradd, it defaults to sh. $ useradd -D|grep SHELL SHELL=/bin/sh. – Sparhawk Apr 10 '14 at 6:48

GNU Bash is the shell used by default in terminals on Ubuntu. However when scripts are executed on system boot then dash is used, as it is dash that is /bin/sh.

This is defined in the $SHELL environmental variable. You can check by typing echo $SHELL in the terminal.

share|improve this answer
+1 great answer (remembering dash)! – user8290 Dec 14 '11 at 23:48

typing the following will display what shell the terminal opened with:

echo $SHELL

However, to find out what shell you are currently in (you may have changed it) type

ps -p $$

e.g. you will see that the shell is bash in the example output

  PID TTY          TIME CMD
 3500 pts/0    00:00:01 bash

Another method is to use

echo $0

this will simply return the name of the current shell.

share|improve this answer
+1 for simplicity echo $0 – djthoms Nov 5 at 19:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.