Ubuntu: Are there any options of bash with which it is invoked?


I find that the default shell that I use when I start Terminal (with Ctrl+Alt+T) is /bin/bash.

And running the built-in command type on bash as:

type -p bash  

returns the result as:


Suggesting the same executable is run when I do Ctrl+Alt+T or say bash.

This shell is the same as an invocation of the command bash with some of its options passed to it right? If yes, what are these options?

As an example, perhaps the -i option gets passed so as to make the bash shell interactive?

PS: Maybe this is related too, but I cannot seem to piece together all the pieces here.


Usually, no, the terminal does not pass any options to bash. bash does, however, assume a set of default options depending on how it was invoked. From man bash, section INVOCATION:

An interactive shell is one started without  non-option  arguments  and  without the -c option whose standard input and error are both connected  to terminals (as determined by isatty(3)), or one started with  the  -i  option.   PS1 is set and $- includes i if bash is interactive, allowing  a shell script or a startup file to test this state.  

An interactive shell further activates other options. Further some defaults apply based on the invocation name (sh vs bash). Reading on (section on set):

-h      Remember  the location of commands as they are looked up          for execution.  This is enabled by default.  -m      Monitor mode.  Job control is enabled.  This  option  is          on  by  default  for  interactive shells on systems that          support it (see JOB CONTROL above)  -B      The  shell performs brace expansion (see Brace Expansion          above).  This is on by default.  -H      Enable !  style history substitution.  This option is on          by default when the shell is interactive.  

Combined, simply invoking bash on a terminal will enable these options.

You can confirm this by checking the value of the $- special variable:

$ echo $-  himBH  

An additional option that maybe set is if your terminal is set to start login shells. In that case -l is explicitly passed by the terminal as an option.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »