Why I can't add fish to /etc/shells?
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
- Change the Shell in Mac OS X Terminal
- Replacing sh with zsh
- OS X refuses to setting fish as default shell(installed via Homebrew) #989
- How to fix /etc/ folder on Mac OS X
Related videos on Youtube
Lokman Boukhoulda
Updated on September 18, 2022Comments
-
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 almost 6 yearsslm'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 thechsh
command to make it your default shell. -
Semo over 5 yearsCan it be you mistyped the path? Yours: "usr/local/blabla" --> My guess: "/usr/local/blabla". There's the root path missing.
-
-
Lokman Boukhoulda almost 6 yearsI 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 almost 6 years@LokmanBoukhoulda - I see your issue now, see updates to the A'er.
-
Lokman Boukhoulda almost 6 yearsI 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 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 almost 6 yearsFind 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 themount -uw / chmod a+x private/etc
Source: [link] (superuser.com/questions/404747/…) . Nowchsh
command worked. -
slm almost 6 years@LokmanBoukhoulda - interesting...I wonder how that even happened?
-
slm almost 6 years@LokmanBoukhoulda - I added the fix to my A'er.