Shell initialization files are ways to persist common shell configuration, such as:
$PATH
and other environment variablesWhich initialization files get sourced by the shell is dependent on the combination of modes in which a particular shell process runs. There are two main, non-exclusive modes:
These modes can be manually activated with the following flags to bash/zsh:
-l
, --login
-i
Here are some common operations and shell modes they result in:
ssh user@host 'echo $PWD'
or with Capistrano: non‑login, non‑interactivebash
: non‑login, interactivebash myscript.sh
: non‑login, non‑interactive#!/usr/bin/env bash
shebang: non‑login, non‑interactiveIn order of activation:
/etc/profile
~/.bash_profile
, ~/.bash_login
, ~/.profile
(only first one that exists)/etc/bash.bashrc
(some Linux; not on Mac OS X)~/.bashrc
$BASH_ENV
/etc/zshenv
~/.zshenv
/etc/zprofile
~/.zprofile
/etc/zshrc
~/.zshrc
/etc/zlogin
~/.zlogin
/etc/profile
~/.profile
$ENV
~/.config/fish/conf.d/*.fish
/etc/fish/conf.d/*.fish
<prefix>/fish/vendor_conf.d/*.fish
(where prefix
is each entry of $XDG_DATA_DIRS
, or /usr/share
and /usr/local/share
)/etc/fish/config.fish
~/.config/fish/config.fish
.bash_profile
or .profile
(1st found).profile
(Ubuntu, once per desktop login session) + .bashrc
.zshenv
+ .zprofile
+ .zshrc
.profile
(Ubuntu, once per desktop login session) + .zshenv
+ .zshrc
.bash_profile
or .profile
(1st found).zshenv
+ .zprofile
+ .zshrc
ssh
or Capistrano:
.bashrc
.zshenv
/usr/libexec/git-core:/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin
$PATH
/etc/paths
, /etc/paths.d/*
~/.MacOSX/environment.plist
- affects all graphical programs/etc/launchd.conf
/etc/environment
This guide was tested with:
On these operating systems/apps:
See also:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4