Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a .bash_profile in my home directory, but it isn't getting run on login. If I do the following, then things seem to be as I expect:

ssh myhost
source ~/.bash_profile

But normally that all happens on login. Thoughts?

share|improve this question
Also make sure that you don't have a ~/.profile or ~/.bash_login, as only one of the three is sourced. (I forgot the exact order.) – grawity Sep 25 '09 at 15:20
Why do you have a different question in the title and different one in the body of your post? – pabouk Nov 9 '13 at 10:25
up vote 111 down vote accepted



Enter your password and state the path to the shell you want to use.

For Bash that would be /bin/bash. For Zsh that would be /usr/bin/zsh.

share|improve this answer
+1 - not sure why the OP decided that editing the password file was a better choice, but this is the best answer – kdgregory Sep 25 '09 at 12:51
Yeah beat me to it, this is the standard way. – John T Sep 25 '09 at 13:49
And on ubuntu the path to the shell you want to use is... /bin/bash (and /bin/sh is not the same) – Harry Wood Mar 2 '12 at 1:01
Or you can use sudo chsh -s /bin/bash username – Oleg Vaskevich Jan 21 '14 at 4:03
You must log out and log back in to see this change. – Neil Traft Jul 6 '14 at 21:59

On top of akira's answer, you can also edit your /etc/passwd file to specify your default shell.

You will find a line like this example:


The shell is specified at the end.

share|improve this answer
Better to use the 'chsh' command as suggested by akira -- less chance to screw something up by mistake. – Lars Haugseth Sep 25 '09 at 13:17
not to mention 'chsh' is available when you can't write to /etc/passwd – quack quixote Oct 7 '09 at 11:30
But if you so have access to modifying the /etc/passwd and you're careful, John's answer is making good use of the tools the system provides. – AJP Apr 26 '14 at 11:00
You must log out and log back in to see this change. – Neil Traft Jul 6 '14 at 22:01
If you're running a server without user passwords - providing access only through public/private ssh keys ... it also makes a lot of sense. chsh requires a password. – Keith John Hutchison Sep 10 '15 at 2:42

You might check your terminal program. It might be configured to run /bin/sh rather than /bin/bash

Bash executes .bash_profile only for login sessions. .bashrc is executed for all bash sessions, not only login sessions. Try sourcing .bash_profile from .bashrc (avoid circular dependency!) or configuring your terminal program to run /bin/bash -l as a shell program.

share|improve this answer
terminal program has nothing to do with the problem because it is the sshd on the remote machine, which spawns the new shell. – akira Sep 26 '09 at 4:31

One alternative is to rename your startup script into .profile. This file is being source by most Unix shells.

share|improve this answer

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.