Linux – Why is it not recommended to set the default shell of the root user to a non-POSIX shell

bashfishlinuxposixshell

I am going to change my root’s default shell from bash to fish. As far as I know, fish is a not a POSIX standard shell. On the other hand, maybe the kernel or other things in the system have a relation with POSIX standards, so setting root's default shell to a non-POSIX one is not recommend because it may cause some problem for parts of the OS. I saw people on some topics that advice others not to set the default shell for the root user to a non-POSIX one! Is it right?

Should I change my default shell for root to non-POSIX one or not? (I'll be happy if you explain it with reasons, I am a newbie to Unix-like worlds!)

Best Answer

Making fish your default login shell will mean the SHELL env var will be set to fish. Many programs (e.g., vim, tmux) use that as the shell to use to execute shell commands unless you explicitly configure them to use another shell (e.g., /bin/sh). Because those shell commands have a high likelihood of containing POSIX shell syntax the commands won't be executed correctly by fish. This means you are more likely to experience seemingly random, frustrating, problems.

You can set fish as your default login shell. I do so on my two main computers. But I'm an experienced UNIX user who is aware of the potential problems this can cause. I also know how to work around them. For example, by adding set shell=/bin/sh to my vimrc config file. If you're inexperienced or just don't want to have to deal with the extra configuration that will be required it is best to leave your login shell set to bash or some other POSIX shell. Then launch fish from that shell when in interactive mode. This is also safer because you are more likely to screw up your fish config in a manner that makes it impossible to start an interactive fish session. If you've made fish your default login shell you'll then be unable to log in.

Bottom line is that if you are an inexperienced UNIX CLI user or new to fish don't set it as your default shell. If you're an experienced UNIX CLI user and have been using fish for a few weeks and are confident you can correctly configure it feel free to make it your default shell.

Related Question