Unix & Linux
shell users login root
Updated Fri, 20 May 2022 06:59:17 GMT

Is it bad practice to set root's shell to something other than the default?


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?




Solution

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.





Comments (5)

  • +0 – This happened to me when I upgraded from FBSD 7.2 to 8.0 and I forgot to rebuild bash. I booted in single user mode to fix, but it only worked because /bin/sh was still linked to FBSD's fork of bourne and not bash. — Oct 03, 2010 at 03:32  
  • +0 – just to make things clearer, if I install say zsh and somehow /usr is damaged I will have problem? but my system have /bin/sh pointing to /bin/bash and bash itself, why wouldn't sh be affected? — Oct 03, 2010 at 10:52  
  • +1 – Defaults for root "guarantee" that the system will boot - the upgrade guide will take care about being able to log into root at least. However it may not be the case for anything else. The solution is to duplicate root account by toor with non-default shell for everyday use and keep root as is. — Oct 03, 2010 at 17:19  
  • +1zsh should not be in /usr/bin/ if it is it was installed wrong. all shells should be in /bin — Oct 23, 2010 at 23:18  
  • +1 – @xenoterracide: zsh on Gentoo is in /bin but keeps some files in /usr/share. Also I clearly stated that problem is during login during boot (when some service fails). — Oct 24, 2010 at 23:54