1

First I installed fish and then I wanted to test zsh so I installed it. Actually I'm using zsh and it works perfect (at the moment): I can switch themes, enable plugins, etc...

But when I do:

echo $SHELL

it should return /bin/zsh, and by surprise it returns /usr/bin/fish

I'm using Kubuntu 14.04. Is it ok, or should I fix it?

heemayl
  • 91,753
Unix
  • 197
  • @kos, It's similar but not the same. He asks how to switch from zsh to bash, while I'm already using zsh as I wanted. It's just this output that I don't understand. – Unix Mar 21 '16 at 12:57
  • Well the linked question is a superset of your question: it asks why that happens and how to change that (not how to switch from Zsh to Bash), and has a good answer: so I'd say this question fits all the requirements to be closed as a duplicate of that question, unless I'm missing something. – kos Mar 21 '16 at 13:20
  • 1
    @kos, you're right. The answer you linked contains a reference of the file /etc/passwd. Now I also found this related one with very interesting information about chsh command and the mentioned file: http://askubuntu.com/questions/195361/chsh-s-usr-bin-zsh-not-working?rq=1 – Unix Mar 21 '16 at 14:50

1 Answers1

5

SHELL always (well, if not set manually) expands to the login shell (defined in /etc/passwd) of the user, not necessarily the shell user currently using.

You can cross check with:

grep -Po '^username:.*:\K[^:]+$' /etc/passwd

Replace username with your real username.

If you want to change your login shell, modify /etc/passwd or better use chsh:

chsh -s /path/to/shell username
heemayl
  • 91,753
  • Well, it returns the same as before: /usr/bin/fish. When I change it with the command chsh (as root), it returns: «Authentication error». – Unix Mar 21 '16 at 12:52
  • Opening the file /etc/passwd I can see the first line: «root:x:0:0:root:/root:/bin/zsh5» – Unix Mar 21 '16 at 12:54
  • @Gerard Exactly, it returned /usr/bin/fish expectedly..check for which user you are running the command.. – heemayl Mar 21 '16 at 12:56
  • So it's the expected output... I thought it was wrong. Then it's everything ok. Thanks! :) – Unix Mar 21 '16 at 12:59
  • I edited manually the file /etc/passwd, the line 34 where there's my username :/home/gerard:/usr/bin/fish, to this: :/home/gerard:/usr/zsh, I restarted the system and now it returns the right shell. I don't think that fish was the expected result because I deleted it before installing zsh. – Unix Mar 21 '16 at 14:31
  • @Gerard What i wrote in the answer is correct..perhaps you are tripping around the usernames as i mentioned in my last comment.. – heemayl Mar 21 '16 at 14:58
  • In fact, heemayl, I did a mistake in my last answer. The right path to the zsh shell is /bin/zsh/ instead of /usr/zsh. To be honest, I don't understand how the username works on it (and I only have one user). After editing manually passwd and logging in, the command chsh -s /bin/zsh works without errors and echo $SHELL returns the same as listed in /etc/shells. I think everything is fixed. Thanks for your patience. – Unix Mar 21 '16 at 15:37
  • 2
    @Gerard, get out of the habit of manually editing files. Get out of the habit of working as root. You're inevitably going to make an accident and screw up your system. It happens to everybody. Get comfortable using the correct commands (chsh) as the right user. Get comfortable using the sudo command when you temporarily need to elevate your privileges. – glenn jackman Mar 21 '16 at 16:46
  • Yes, trying it as root was a mistake @glennjackman because I didn't understand the scope of the users of the shell. Editing files... Well, I know it was a risk, still I did a backup of the original file. 99% of the times I use sudo when it's needed instead of sudo su. Thanks for your advices :) – Unix Mar 21 '16 at 17:08