Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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

$ echo $0
-bash

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?

share|improve this question

migrated from serverfault.com Aug 5 '12 at 3:59

This question came from our site for professional system and network administrators.

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.

share|improve this answer

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

share|improve this answer
    
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 '12 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 '12 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 '12 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 '12 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.

share|improve this answer

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.

share|improve this answer

Jason,

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).

share|improve this answer

Your Answer

 
discard

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