2

I'm trying to become the root on my terminal with sudo -i command, but the system display sudo: /usr/local/bin/fish: command not found. I tried to set the fish shell as default, but I got a problem. Could anyone be able to tell me what I could do to fix the problem?

I tried to set fish shell as default with first sudo echo /usr/local/bin/fish >> /etc/shells and after chsh -s /usr/local/bin/fish. However, it looks like I have more than one usr/local/bin/fish file in /usr/shells. (In fact, I followed from there)

Thanks in advance!

P.S. I know now the file is not usr/local/bin/fish, but usr/local/bin. I've succeeded to set fish shell as default, but I'm still having the sudo -i problem.

Sandra Ross
  • 777
  • 3
  • 10
  • 20
  • You're gonna have to give us a little history. How did you set it as default? How did you install it? – TheWanderer Nov 11 '16 at 01:01
  • @Zacharee1 Ok, it's done – Sandra Ross Nov 11 '16 at 01:09
  • Those are instructions for macOS. You are on Ubuntu, right? – TheWanderer Nov 11 '16 at 01:10
  • Yes, I am with Ubuntu. However, It seems that procedure also work in Ubuntu (see http://stackoverflow.com/questions/453236/how-to-set-my-default-shell-on-mac). – Sandra Ross Nov 11 '16 at 01:13
  • I think you're getting that error because Ubuntu doesn't have `fish` installed by default. You need to use `sudo apt install fish`. – TheWanderer Nov 11 '16 at 01:16
  • Yes, I did that. It is indicated `chsh: /usr/local/bin/fish is an invalid shell ` – Sandra Ross Nov 11 '16 at 01:17
  • 1
    I doubt `apt` would have installed it to `/usr/local` - more likely `/usr/bin/fish`. Also `sudo echo ...` to write to `/etc/shells` isn't going to work - see [When using sudo with redirection, I get 'permission denied'](http://askubuntu.com/questions/230476/when-using-sudo-with-redirection-i-get-permission-denied) – steeldriver Nov 11 '16 at 01:20
  • @steeldriver I'll try to localize `fish` – Sandra Ross Nov 11 '16 at 01:21
  • Ok, now I've succeeded to set up fish shell as default, but I'm still having the problem of `̀sudo: /usr/local/bin/fish: command not found`. – Sandra Ross Nov 11 '16 at 01:29
  • What's the output of `which fish`, `grep fish /etc/shells`, and `getent passwd root | cut -d: -f7`? – David Foerster Nov 11 '16 at 08:23
  • @SandraRoss, I encountered that error message, and I think my answer below solves that problem. – Chai T. Rex Nov 11 '16 at 19:55

1 Answers1

6

To replace a bad default shell for root with fish:

  1. Install fish (with sudo apt install fish if you want Ubuntu's package)
  2. Run sudo nano /etc/pam.d/chsh
  3. Insert a # in front of the line auth required pam_shells.so
  4. Save and exit by pressing Ctrl+O, Enter, Ctrl+X
  5. Run sudo chsh -s $(which fish) (remove the $ if you're doing all this within fish)
  6. Run sudo nano /etc/pam.d/chsh
  7. Remove the # you inserted
  8. Save and exit by pressing Ctrl+O, Enter, Ctrl+X

Now, you can test that the shell is set properly with sudo -i.

Chai T. Rex
  • 5,126
  • 1
  • 24
  • 48