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 bash source ~/.bash_profile
But normally that all happens on login. Thoughts?
Enter your password and state the path to the shell you want to use.
For Bash that would be
For Zsh that would be
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.
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.
One alternative is to rename your startup script into .profile. This file is being source by most Unix shells.
Change shell for user:
$ sudo usermod -s /bin/bash username
-s, --shell SHELL new login shell for the user account
There's not enough information in your question for me to say for sure, but I've hit the same problem before. Assuming you've already get /bin/bash set in your password entry, it may be the way your terminal launches.
If you're trying to launch a GUI terminal, say
gnome-terminal you may be expecting the shell to read your bash startup files. However, this doesn't happen on Ubuntu and maybe other systems by default.
The way I've fixed it on Ubuntu is to edit the gnome-terminal preferences, and set the startup command to be
-l is short for
--login. This tells bash to startup as as login shell, which causes it to load the startup scripts as you get when logging in via ssh.
I'm sure there's a good rationale for this being the way it is, but I found it surprising and a more than a bit annoying as I share the same profiles across linux, cywgin and macos systems.