<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
  "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
  <!ENTITY % general-entities SYSTEM "../../general.ent">
  %general-entities;
]>

<sect1 id="ch-scripts-profile">
  <title>The Bash Shell Startup Files</title>
  <?dbhtml filename="profile.html"?>

  <indexterm zone="ch-scripts-profile">
    <primary sortas="e-/etc/profile">/etc/profile</primary>
  </indexterm>

  <para>The shell program <command>/bin/bash</command> (hereafter
  referred to as <quote>the shell</quote>) 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 <filename class="directory">/etc</filename>
  directory provide global settings. If an equivalent file exists in the
  home directory, it may override the global settings.</para>

  <para>An interactive login shell is started after a successful login,
  using <command>/bin/login</command>, by reading the
  <filename>/etc/passwd</filename> file. An interactive non-login shell
  is started at the command-line (e.g.,
  <prompt>[prompt]$</prompt><command>/bin/bash</command>). 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.</para>

  <para>For more information, see <command>info bash</command> under the
  <emphasis>Bash Startup Files and Interactive Shells</emphasis> section,
  and <ulink url="&cblfs-root;index.php/Bash_Startup_Files">Bash Startup
  Files</ulink> in CBLFS.</para>

  <para>The files <filename>/etc/profile</filename> and
  <filename>~/.bash_profile</filename> are read when the shell is
  invoked as an interactive login shell. Create a base
  <filename>/etc/profile</filename> that will setup locale information and load
  any bash auto completion files that may be on the system. This script also
  sets the <envar>INPUTRC</envar> environment variable that makes Bash and
  Readline use <filename>/etc/inputrc</filename>.</para>

<screen><userinput>cat &gt; /etc/profile &lt;&lt; "EOF"
<literal># Begin /etc/profile

source /etc/locale.conf
for f in /etc/bash_completion.d/*.sh; do source $f; done; unset f
export INPUTRC=/etc/inputrc

# End /etc/profile</literal>
EOF</userinput></screen>

</sect1>
