I have a hosted Debian server. When I log in via ssh, I'm greeted with a sh environment. How do I change it so I start in a bash environment?
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
/etc/passwd where the last entry is the default shell. Make it
Alternatively, you could alter alter the system default of
/bin/sh not being bash.
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
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
With this, you can achieve desired effect of having
bash as interactive shell without changing any user settings (no
usermod), and it will work for all users who currently have shell set to
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.
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