How do I start in bash when ssh'ing into my server?

Solution 1:

As a regular user, you can change your default login shell using the chsh command. Here is an example:

chsh -s /bin/bash

Another option is to use usermod as root:

usermod -s /bin/bash username

Solution 2:

For the case where you're trying to use a shared account (for whatever reason) and can't change the default shell, then you can run

ssh -t <user@hostname> bash -l

If you need to keep your environment from some other shell, then you can run that shell first; for example

ssh -t <user@hostname> ksh -c bash -l

Solution 3:

You edit /etc/passwd where the last entry is the default shell. Make it /bin/bash.

Alternatively, you could alter alter the system default of /bin/sh not being bash.

Solution 4:

You need to edit your user profile, you can do this directly by editing the /etc/passwd file, or you can use the usermod command to do it for you. The syntax you're looking for looks something like this:

usermod -s /bin/bash joeuser

Solution 5:

Default system shell /bin/sh in recent Ubuntu releases is configured to be /bin/dash. By simply running following command:

sudo dpkg-reconfigure dash

you can change it back to old default of /bin/bash.

With this, you can achieve desired effect of having bash as interactive shell without changing any user settings (no chsh or usermod), and it will work for all users who currently have shell set to /bin/sh.

There is only one small downside to this: Ubuntu boot time might slightly increase, because dash takes less memory to load and slightly faster to run (no wonder - it is so limited in features). But I think it will be rather difficult to measure this effect, especially for hosting environment.

Also, it is sometimes annoying to see shell scripts that fail to work properly because they use some bash advanced features which are not supported by dash. Using this recipe will make sure this will not happen.

For more information, see Ubuntu wiki about this issue.