sh session reads the user's
~/.profile upon invocation. If the
ENV variable is set to a filename after doing that, and if that file exists, the shell will use that file to further initialize the login session.
Interactive shells that are not login shells will only use
ENV is set, but will not read
Non-interactive shell should not use either of these two files.
Usually, one exports
ENV at the end of one's
ENV="$HOME/.shrc" # for example
export ENV # may be done as export ENV="..." too, in most shells.
This is, for example, what
bash does if it's invoked as
sh or with
One may use these two files (
$ENV) for whatever one wishes, but the profile is where you might want to set and export environment variables that only needs to be set once (
PATH etc.), fire up any
fetchmail process or other user daemon that you wish to use etc., while the
$ENV file is where you set up specific things for this particular shell session/TTY, such as setting
GPG_TTY (if you're using GnuPG), setting up aliases (since aliases are not inherited by subshells) etc.
ksh93 shell uses
$ENV by default, but interprets
$ENV in a specific way. If
$ENV starts with
././, then no system-wide configuration file will be used (e.g.
~/.login is not used by
ENV is set to this filename or it is explicitly sourced from