On a normally-configured system, if you changed your shell with
chsh, then the chosen shell is valid, so your shell is starting, but there is a problem with one of its configuration files that causes it to exit immediately.
Try pressing Ctrl+C very quickly after logging it. Depending on how loaded the machine is, the time window during which this will not kill the shell but will instruct it to stop parsing configuration files may or may not last long enough to get a realistic chance of success. Try it a few times, ideally during some heavy disk activity so that the files involved aren't in the disk cache.
If the problem is in
.zshrc, you can still log in non-interactively. This is impossible on the console, but can be done over the network:
ssh machinename 'mv .zshrc bad.zshrc'
If you have FTP (not SFTP) access, you can get rid of any configuration file this way, because FTP doesn't read any configuration files. With SSH or SFTP, a shell is always invoked, so you won't be able to log in if the problem is with
If you're unable to access your account, you'll need to fix this via the root account. If you have a root password, just log in as root on the console. If you only have access to the root account via sudo, you've locked yourself out, so assuming that nobody else can do it for you, you'll need to have physical access to the machine and you'll need to reboot it. At the bootloader prompt (you may need to press and hold Shift to make it appear), add
init=/bin/sh at the end of the kernel command line (the line that starts with
linux). See the Arch Wiki for more details.
Once you get access from the root account, you may either change the shell back to one that worked, or guess the file that caused the problem. Zsh reads five configuration files in
/etc and 5 in your home directory.
Once you've recovered access to your account, if you don't know what file caused the problem, add
set -x to
~/.zshenv. This will cause zsh to print all commands before executing them. Run
zsh -l to run a login shell, or log in on another terminal, and see what breaks.
Before changing your shell back to zsh, test that
zsh -l works. After running
chsh, check that you can log in on another terminal before logging out.