If you can't run chsh
because you don't have admin privileges, talk to someone who does.
Most likely you can't use chsh
as non-root because the system you're using is configured so that chsh
wouldn't work, for example because the system uses NIS or LDAP rather than just the /etc/passwd
file. Or perhaps your system's administrator just wants to maintain some control.
The procedure for changing your shell depends on your organization's policies. There may be a local command that does what chsh
normally does. Or you may need to submit a support ticket requesting a shell change.
Most of the other answers are good, but if your administrators are reasonably responsive you might not want to bother hacking your startup scripts. I'd probably just invoke zsh -l
manually after logging in until the administrator gets around to updating my account.
Another thing to keep in mind: Sometimes different shells can use the same startup files. For example, sh
and bash
can both execute $HOME/.profile
, and csh
and tcsh
can both execute $HOME/.login
and $HOME/.cshrc
(though shell-specific startup files like .bashrc
, .bash_profile
, and .tcshrc
can override those). If your default shell is /bin/csh
and you want to use /bin/tcsh
, updating your .login
to invoke /bin/tcsh -l
could create an infinite loop. zsh
doesn't happen to execute bash
-specific startup files, so that's not an issue for you.
Most shells set variables that identify which shell you're running ($BASH_VERSION
, $tcsh
, $ZSH_VERSION
). If you're going to write startup code to invoke your preferred shell, it's not a bad idea to enclose it in an if
so it's executed only if you're not already running that shell. Using the code from konsolebox's answer:
if [ "${ZSH_VERSION:-unset}" = "unset" ] ; then
export SHELL=/bin/zsh
exec /bin/zsh -l
fi
(The added complication of checking "${ZSH_VERSION:-unset}"
rather than just "$ZSH_VERSION"
allows for the possibility that you've done set -o unset
, an option that causes a reference to an undefined variable to be an error.)
zsh
on the.bashrc
file. Logout and login and done!zsh
on the first line?bash
is called explicitly. Better place it in.bash_profile
instead.