~/.profile, when it is invoked as a login shell. The reason is that zsh has enough incompatibilities with standard shells to break scripts.
Zsh does run
~/.profile if it is called as
ksh. But if your objective is to get a zsh prompt when you log in, that's no help.
You can make
/bin/sh your login shell and include
export SHELL=/bin/zsh in your
~/.profile. Then when you open a terminal, the terminal will launch zsh (except for a few terminal emulators don't obey the
$SHELL setting). But you will still have
sh when you log in over ssh. This can be remedied by including
exec zsh at the end of
~/.profile (this replaces the running shell by zsh), but you need to be careful only to do that for interactive logins and not when
~/.profile is included from other scripts such as the X session start (a good test is the name of the parent process obtained by
ps -o comm= $PPID: if it's
su, then it's safe to
The easiest solution to both work with zsh and run
~/.profile is to create a
~/.zprofile that enters sh emulation mode while it runs
If you have a recent enough zsh (on Ubuntu, that means since lucid, I think), you can simplify this to
emulate sh -c '. ~/.profile'.
~/.profile is loaded by login shells. The login shell is the first process that is started when you log in in text mode, for example on a text console or via ssh. By default, on most Linux machines, the login shell is bash, but you can change it with the
chsh command, or through some other tool such as the “User Settings” in Ubuntu. When it's a login shell, bash reads
~/.bash_profile if it exists and
~/.profile, whereas zsh reads only
~/.zprofile (because its syntax is not completely compatible with a traditional sh). Under most configurations,
~/.profile is also loaded by the X session startup scripts when you log in in a graphical display manager.
When you start a terminal emulator and get a shell prompt, or when you start a shell explicitly, you get a shell that is not a login shell. Since
~/.zprofile) is for commands that you want to execute when you log in, a non-login shell doesn't read this file. Instead, when you start an interactive zsh, it reads
~/.zshrc. (Zsh reads
~/.zshrc in all interactive shells, whether they are login shells are not; bash, strangely, never reads
~/.bashrc in login shells.)
~/.profile contains environment variable definitions, and might start some programs that you want to run once when you log in or for the whole session;
~/.zshrc contains things that must be done for every shell instance, such as alias and function definitions, shell option settings, completion settings, prompt settings, key bindings, etc.