11.8. The Bash Shell Startup Files

The shell program /bin/bash (hereafter referred to as “the shell”) uses a collection of startup files to help create an environment to run in. Each file has a specific use and may affect login and interactive environments differently. The files in the /etc directory provide global settings. If an equivalent file exists in the home directory, it may override the global settings.

An interactive login shell is started after a successful login, using /bin/login, by reading the /etc/passwd file. An interactive non-login shell is started at the command-line (e.g., [prompt]$/bin/bash). A non-interactive shell is usually present when a shell script is running. It is non-interactive because it is processing a script and not waiting for user input between commands.

For more information, see info bash under the Bash Startup Files and Interactive Shells section, and Bash Startup Files in CBLFS.

The files /etc/profile and ~/.bash_profile are read when the shell is invoked as an interactive login shell. Create a base /etc/profile that will load any Bash auto completion files that may be on the system, and set the INPUTRC environment variable that makes Bash and Readline use /etc/inputrc:

cat > /etc/profile << "EOF"
# Begin /etc/profile

for f in /etc/bash_completion.d/*
  if [ -e ${f} ]; then source ${f}; fi
unset f

export INPUTRC=/etc/inputrc