How do I make Bash my default shell on Ubuntu?

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?


Solution 1:

Use:

chsh

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.

Solution 2:

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:

john:x:1000:1000:john,,,:/home/john:/bin/sh

The shell is specified at the end.

Solution 3:

Enable bash:

$ /bin/bash

Change shell for user:

$ sudo usermod -s /bin/bash username

where:

  -s, --shell SHELL             new login shell for the user account

Solution 4:

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.

Solution 5:

To make any shell your default, first verify it is installed and recognized on your computer by looking at the contents of /etc/shells:

$ cat /etc/shells
# /etc/shells: valid login shells
/bin/sh
/bin/bash
/usr/bin/bash
/bin/rbash
/usr/bin/rbash
/bin/dash
/usr/bin/dash
/usr/bin/fish

Then use chsh to change your shell:

$ sudo chsh -s /usr/bin/bash $(whoami) # or sudo chsh -s /bin/bash $(whoami)

References

  1. https://linux.die.net/man/1/cat
  2. https://linux.die.net/man/1/whoami
  3. https://linux.die.net/man/5/shells
  4. https://linux.die.net/man/1/chsh