Bash Startup Files
bash is started it runs a series of scripts to prepare the environment
for user. These scripts, for example, set the environment variables, create
command aliases, run programs.
There are two main types of a shell instance, interactive and noninteractive. However, noninteractive shells (such as those running shell scripts) usually don’t read any startup files. To run a noninteractive shell as a login shell, to force it to run startup files, start the shell with the
Interactive shell can be a:
- login shell - a shell started by the
loginprogram or a remote login server such as SSH (it’s startup files are a place for variables like
PS1and startup programs like
- non-login shell - additional shell you run after you log in - ex. shell inside an X-based terminal (it’s startup files are a place for aliases and functions)
… to find out run
echo $0 | perl -lne 'print /^\-/ ? "" : "non-", "login shell"'
|Login shell||Non-login shell|
Creating a symlink between
~/.bash_profile will ensure that the same startup scripts run for both login and non-login sessions. Debian’s
~/.bashrc, which has the same effect.