6

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!)

  • 2
    I have a suspicion the recommendation is mainly due to other shells living in /usr and/or having library dependencies there (which is relevant to split-/usr systems). Besides that, root's login shell isn't used by the system at all – as long as /bin/sh itself is unaltered, it should be fine. – user1686 Apr 24 '18 at 9:43
2

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.

| improve this answer | |
  • 1
    The question is not as much about "your default shell", it's about "root’s default shell". Probably this distinction and the importance of root account are reasons the question arose in the first place. Your answer seems to ignore this aspect, you don't mention root at all. Does this mean your answer applies to non-root and root accounts as well? and you don't see the need to treat them differently in this matter? – Kamil Maciorowski Apr 24 '18 at 17:04
  • No, I do not think there is any reason to treat root and non-root accounts differently with respect to this question. That is why I didn't couch my answer in terms of the root account. The likelihood of running into problems is actually higher for a non-root account because you're more likely to be running apps (e.g., an IDE) that are affected by the default shell not being POSIX compliant. – Kurtis Rader Apr 24 '18 at 20:31
  • I always had the impression that the main reason not to change root's shell is that root is the user account you need for system recovery when you can barely do anything with the computer. So the less exotic the shell, the better. In particular, if the /usr partition or package manager is not working right, you may have a problem if you installed the shell using those. Also, it's a good habit to use sudo as much as possible, and then it doesn't matter much whether root has a fancy shell. – Lassi Apr 23 '19 at 20:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.