The Zsh Startup Files

Like most shells, zsh processes a number of system and user startup files. It is very important to understand the order in which each file is read, and what conditions cause various files to be ignored. Otherwise, you may be entering commands and configurations into your startup files that aren't getting seen or executed by zsh.

The Startup Process

In the below description, zsh looks for user startup files in the user's home directory by default. To make it look in another directory, set the parameter ZDOTDIR to where you'd like zsh to look.

When zsh starts up, the following files are read (in order):

Logging Out

When a user logs out, /etc/zlogout is read, followed by ZDOTDIR/.zlogout.

What do the terms mean?

A login shell is generally one that is spawned at login time. (IE, by either /bin/login or some other daemon that handles incoming connections). If you telnet, rlogin, rsh, or ssh to a host, chances are you have a login shell.

An interactive shell is one in which prompts are displayed and the user types in commands to the shell. (IE, a tty is associated with the shell)

For example, if I run the command

ssh SOME_HOST some_command

I will be running (presumably) a non-interactive program called some_command. This means that zsh will not be an interactive shell, and ignore the corresponding files. Zsh should, however, be a login shell, and read the appropriate files.


Another directory besides /etc can be used for the global files. This is determined during the installation of zsh.