I want my default shell to be bash. However, whenever I log into my server, the shell is apparently -bash:

$ echo $0

If I run bash, I'm of course switched to bash for that session, but it doesn't stick, even if I do chsh -s /bin/bash.

Is there some step that I'm missing if I want bash to be my default shell?

5 Answers 5


After bash runs, it prepends its name with - to indicate that it's a login shell.

The SHELL variable will contain the path to the actual binary.


You are running bash. Try echo $BASH, which will point to the binary executed.

  • echo $BASH gives me /bin/bash. If I'm running bash, why isn't my .bashrc loaded until I actually type bash?
    – Jason Swett
    Feb 22, 2012 at 15:56
  • Okay. Could you please help me understand exactly what I need to ask? You understand my overall problem, right? I log in and things are not how I want them to be. I type bash and the problem goes away, but I don't want to have to run bash every time I log in.
    – Jason Swett
    Feb 22, 2012 at 16:13
  • @JasonSwett: Check the bash man page. It says explicitly that a login shell does not read .bashrc. Read the 'INVOCATION' section.
    – Dan Andreatta
    Feb 22, 2012 at 16:18
  • Okay. My goal is to get my shell to behave the same as every other shell I've used in my life, i.e. my .bashrc is loaded and colors are turned on. Is it more complicated to achieve this than I understand?
    – Jason Swett
    Feb 22, 2012 at 17:03

The -bash indicates that you're running bash as your login shell.

If you run /bin/bash from the login shell and run echo $0, then you're seeing the currently running command that was executed from the login shell (but not the login shell itself).

Long story short, you're running bash as your login shell. You can check your designated login shell by looking for your username in /etc/passwd.


Are you by any chance logging into a system that gets its user names over NIS? In that case you need to use ypchsh to change your login shell info on the server.



From your comments at SvenW's answer, your actual problem seems a bit different to how you describe it in your question.

Why don't you edit your question? :-)

In the mean while you could have a look at this post, it seems to address your problem. In particular you could add

source ~/.bashrc

to the file .bash_profile in your home directory (or create it, if it does not exist).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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