Why I can't add fish to /etc/shells?

10,851

You're doing it wrong. You should be using the chsh command to change your user's shell.

$ chsh -s /usr/local/bin/fish

OSX

On OSX you apparently have to add this to the /etc/shells file as described in this issue titled: OS X refuses to setting fish as default shell(installed via Homebrew) #989.

To do this you need to run this command to add it to /etc/shells:

$ echo "/usr/local/bin/fish" | sudo tee -a /etc/shells

After that this file will look like this:

$ cat /etc/shells
# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells.

/bin/bash
/bin/csh
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh
/usr/local/bin/bash
/usr/local/bin/fish

With the above complete, try the chsh -s ... command again and it should work.

Why?

This issue seems to arise with how fish was installed. If you use brew install fish then it's likely that fish was properly added to /etc/shells. If you install fish through some other means, then it's likely that it did not get added as an entry to the /etc/shells file.

Secondary issue

In some cases the permissions on /etc itself may be the issue.

$ ll /etc
lrwxr-xr-x@ 1 root  wheel    11B Jan 26  2016 /etc -> private/etc

$ ll -d private/etc/
drwxr-xr-x  96 root  wheel   3.2K Jul 12 18:53 private/etc/

These permissions are acceptable, if they're not, you can modify them like this:

$ sudo mount -uw / 
$ sudo chmod a+x private/etc

With the above changes, chsh -s ... should now work.

References

Share:
10,851

Related videos on Youtube

Lokman Boukhoulda
Author by

Lokman Boukhoulda

Updated on September 18, 2022

Comments

  • Lokman Boukhoulda
    Lokman Boukhoulda over 1 year

    I'm trying to use fish shell as my default shell on OSX. I have installed fish shell using brew and when I wanted to add it to /etc/shells I got this error:

    tee: /etc/shells: No such file or directory
    

    Here's the command line I used:

    echo "usr/local/bin/fish" | sudo tee -a /etc/shells
    

    Source: https://hackercodex.com/guide/install-fish-shell-mac-ubuntu/

    Is there something wrong with my $PATH?

    • Nasir Riley
      Nasir Riley almost 6 years
      slm's answer works. Even if you successfully add it to /etc/shells which you could just do with a text editor, you'd still have to run the chsh command to make it your default shell.
    • Semo
      Semo over 5 years
      Can it be you mistyped the path? Yours: "usr/local/blabla" --> My guess: "/usr/local/blabla". There's the root path missing.
  • Lokman Boukhoulda
    Lokman Boukhoulda almost 6 years
    I still don't have fish shell added to my shells file. When I enter the command-line $ chsh: /usr/local/bin/fish I get this: chsh: /usr/local/bin/fish: non-standard shell I have read from the source I mentioned above that I should add fish shell to /etc/shells before I use this command-line
  • slm
    slm almost 6 years
    @LokmanBoukhoulda - I see your issue now, see updates to the A'er.
  • Lokman Boukhoulda
    Lokman Boukhoulda almost 6 years
    I got this error $ cat: /etc/shells: No such file or directory When I entered the following command-line: $ ls -l /etc/shells I got this message: lrwxr-xr-x 1 user admin 29 9 Jun 00:20 /etc/shells -> ../Cellar/fish/2.7.1/bin/fish I'm confused, does the file /etc/shells exist?
  • slm
    slm almost 6 years
    @LokmanBoukhoulda - I'd delete that link and simply re-make that file using the one I showed. sudo unlink /etc/shells.
  • Lokman Boukhoulda
    Lokman Boukhoulda almost 6 years
    Find the solution for my problem. My /etc/folder was private and that's why it gave me /etc/shells: No such file or directory . So by making some research I found the steps to make it public. Here's the mount -uw / chmod a+x private/etc Source: [link] (superuser.com/questions/404747/…) . Now chshcommand worked.
  • slm
    slm almost 6 years
    @LokmanBoukhoulda - interesting...I wonder how that even happened?
  • slm
    slm almost 6 years
    @LokmanBoukhoulda - I added the fix to my A'er.