1

e.g. I use ssh to login into a Linux server with zsh. Then in the zsh, I type zsh to get a non-login shell. How can I quit the non-login zsh and get back to the login zsh?

2
exit

That will only exit the most recent shell, not the remote server, unless you're in the login shell.

You can see if you're in a login shell by echoing $SHLVL. It will have value 1 if you're in your login shell but will be 2 when you start a subsequent shell.

The variable $0 might also be set to -zsh in the login shell but zsh in others.

  • I find that exit can quit a login-shell as well. – youkaichao Feb 15 at 11:58

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.