6

How do I change my shell to one installed in my home directory? I installed a new zsh in my home directory, which is picked up:

>> which zsh
>> /home/myname/bin/zsh

It's not listed in /etc/shells (and won't be, as I lack permission), so how do I install it?

chsh -s $(which zsh) myname
Changing shell for myname
Password: 
chsh: "/home/myname/bin/zsh" is not listed in /etc/shells
chsh: use -l option to see list
4
  • Perhaps you could exec zsh in your bashrc ?
    – cnicutar
    Feb 7, 2012 at 21:50
  • @cnicutar That works, thanks, but seems a bit of a hack. Is the reason I can't do it properly because sysadmins don't want users to screw up their shells?
    – rxmnnxfpvg
    Feb 7, 2012 at 21:53
  • I don't know the reasoning behind /etc/shells, do tell if you find out.
    – cnicutar
    Feb 7, 2012 at 21:55
  • See this answer for somewhat fail safe way to start zsh from bash superuser.com/a/560732/175441
    – Francisco
    Mar 6, 2013 at 8:15

1 Answer 1

6

The whole point of /etc/shells is so that the administrator can control what users set as their shell. Setting a shell which isn't listed in /etc/shells would therefore be a security hole. The best solution is to ask the administrator to install zsh system wide, but if that's not possible your only option is configuring your current shell (I'm assuming bash) to execute your custom shell. You can do this by adding the following to ~/.bash_profile (this will only affect login shells, whereas ~/.bashrc will also affect non-login shells which may break scripts).

exec ~/bin/zsh
1
  • 1
    If you are on an administered system, and the system administrator says "no" to an installation of zsh, I would think twice - and definitely ask the admin for permission - before installing zsh locally. Call me paranoid, but asking first is definitely better than getting issued a warning notice for violating company policy...
    – DevSolar
    Jun 6, 2012 at 7:27

Not the answer you're looking for? Browse other questions tagged .