Once a friend of mine (who is an experienced Unix/Linux user) told me that setting root’s shell to something other than sh (i.e bash or zsh) might create problems, because some script might assume that the shell is sh and do something weird.
However, I think Ubuntu have default root shell set to bash, and Gentoo uses bash too. Can somebody bust the myth?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
Yes. If system fails during booting you can log into root shell. If you have separate /usr some shells can fail to successfully start.
I’d advice to create account toor (uid 0, gid 0) with non-standard shell while left root with default shell.
Method 2
Should not be an issue.
Shell-script files explicitly encode which shell they are executed with. It is encoded in the first line or other programs or scripts execute a specific shell and give the shell script as argument.
The only program I can think of that uses the user account shell information (besides the login process) is procmail. Really funny if your user has set as shell /bin/false on the mailserver … But you usually do not execute procmail as root.
Another candidate would be the lines in the crontab of root. I don’t know what the policy of crond is which shell to use.
Method 3
Scripts written for the bourne shell will most of the time run against BASH or ZSH or $foo without any problems.
On many Linux systems is no original sh installed, instead its often a symlink against /bin/bash.
If some scripts just “assume” that the shell is explicitly sh, they should be rewritten.
Theres the shebang mechanism to choose which interpreter your script needs. If its the sh, the script should include #!/bin/sh as the first line.
Your default shell setting should not be relevant in this context.
Method 4
I don’t think changing root’s shell would cause any trouble. I seem to remember some unices (maybe some BSD variants?) having tcsh as the default shell for root.
Root logins are rare anyway. Normally, you’d log into your own account and then su or sudo to root.
What matters is that root’s shell should have as few dependencies as possible so as to be usable in a system reparation context. For example, it’s a good idea to have a statically linked root shell; some distributions ship a statically linked version of bash or zsh or sash (a shell with many standard utilities built-in). However this isn’t so important if your system can easily be booted from a rescue CD or USB drive.
Method 5
The login shell of a user does not affect the boot process. You can set this shell to whatever you want. Not all systems have bash and they work fine. Also if it’s /usr/bin/zsh it was installed wrong, all system shells should be in /bin. You shouldn’t, however, change /bin/sh to point to something other than the default (unless you know what you are doing) as many scripts have #!/bin/sh which usually points to bash, when they should have #!/bin/bash because they use bashisms and other behavior that won’t work on zsh or dash.
Method 6
I have bash as default shell for root. I used zsh for some time, but then went back to bash. What shell you use, doesn’t matter much.
It’s only an issue, if more than one person has root access. In that case you may select a ‘common denominator’ which is usually bash, as this is the most widely used shell.
Method 7
In regards to Solaris/illumos the Solaris Root Shell Mini-FAQ mention
Some sysadmins still recommend against changing the root shell on
Solaris systems. Ask why and you may be told that root needs a
statically linked shell which is not dependent on the dynamic
libraries under /usr/lib. This was true in the past but is not
necessarily the case today. Solaris, when properly configured,
is like any other version of Unix and can support whatever shell you
define, for root or any other account.
So, yes, if you are using Solaris or illumos, it is fine to use shells other than sh.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0