Changing default shell to bash

According to multiple sources you should not change the default shell to bash for the root user because it will make the system unbootable.

Is there a safe way to launch bash for root when logging in? Perhaps I can edit /etc/profile or add it to a startup script somewhere?

sh is statically linked and, as such, does not rely on libraries that may reside on filesystems which are not mounted during the boot process, when the shell is needed, or in the event of a failure (or recovery). The implication being that other shells, such as Bash, are reliant on external libraries that may reside on filesystems not available when required.

If it's applicable to your system and that's what the folks over at that HP forum suggest, then it's still sound advice to adhere to. Besides, it's easy to launch bash from your .profile to make that your 'default' shell after login.

1 Like

I would agree that setting the root shell is a dangerous thing as there could be code run at boot that assumes the shell has not been changed. It should run the code that calls in the /sbin/init.d scripts with a sh call, but will that calling script work in bash is another question. You would have to check so much that it's probably not worth it and any patches might undo any adjustments you may have to make.

Could I suggest that you don't login as root directly anyway. Unless this is only ever going to be a personal system, there is a likelihood that you will need to share the password at some point.

A more controlled/audit-able way is to log in as a standard user and use su to become the root user. If you have sudo privileges, then it's even easier. You could put a one-line script in your path similar to this:-

sudo su - root -s /bin/bash

I would consider preventing root login except from the console, both for telnet and SSH connections. Change and secure the root password and have that only used in a dire emergency.

I hope that this helps.

1 Like