[b32e803] | 1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
| 2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
|
---|
| 3 | <!ENTITY % general-entities SYSTEM "../general.ent">
|
---|
| 4 | %general-entities;
|
---|
| 5 | ]>
|
---|
| 6 | <sect1 id="ch-scripts-profile">
|
---|
| 7 | <title>The Bash Shell Startup Files</title>
|
---|
| 8 | <?dbhtml filename="profile.html"?>
|
---|
| 9 |
|
---|
[f67f5cf] | 10 | <indexterm zone="ch-scripts-profile"><primary sortas="e-/etc/profile">/etc/profile</primary></indexterm>
|
---|
| 11 |
|
---|
| 12 | <para>The shell program <command>/bin/bash</command> (hereafter
|
---|
| 13 | referred to as just <quote>the shell</quote>) uses a collection of startup files to
|
---|
[b32e803] | 14 | help create an environment to run in. Each file has a specific use and
|
---|
| 15 | may affect login and interactive environments differently. The files in
|
---|
| 16 | the <filename class="directory">/etc</filename> directory generally provide global
|
---|
| 17 | settings. If an equivalent file exists in your home directory it may
|
---|
| 18 | override the global settings.
|
---|
| 19 | </para>
|
---|
| 20 |
|
---|
| 21 | <para>An interactive login shell is started after a successful login, using
|
---|
[f67f5cf] | 22 | <command>/bin/login</command>, by reading the
|
---|
[b32e803] | 23 | <filename>/etc/passwd</filename> file. An
|
---|
[f67f5cf] | 24 | interactive non-login shell is started at the command-line (e.g.,
|
---|
[b32e803] | 25 | <prompt>[prompt]$</prompt><command>/bin/bash</command>). A non-interactive
|
---|
| 26 | shell is usually present when a shell script is running. It is non-interactive
|
---|
| 27 | because it is processing a script and not waiting for user input between
|
---|
| 28 | commands.</para>
|
---|
| 29 |
|
---|
| 30 | <para>For more information see <command>info bash</command> --
|
---|
| 31 | <emphasis role="strong">Nodes: Bash Startup Files and Interactive
|
---|
| 32 | Shells.</emphasis></para>
|
---|
| 33 |
|
---|
| 34 | <para>The files <filename>/etc/profile</filename> and
|
---|
| 35 | <filename>~/.bash_profile</filename> are read when the shell is invoked
|
---|
| 36 | as an interactive login shell.</para>
|
---|
| 37 |
|
---|
[181a690] | 38 | <para>A base <filename>/etc/profile</filename> created below sets some
|
---|
| 39 | environment variables necessary for native language support. By setting them
|
---|
| 40 | properly, you get:
|
---|
| 41 | </para>
|
---|
| 42 | <itemizedlist>
|
---|
| 43 | <listitem><para>the output of programs translated into your native
|
---|
| 44 | language;</para></listitem>
|
---|
| 45 | <listitem><para>correct classification of characters into letters, digits and
|
---|
| 46 | other classes - this is necessary for Bash to accept non-ASCII characters
|
---|
| 47 | in command lines properly in non-English locales;</para></listitem>
|
---|
| 48 | <listitem><para>the alphabetical sorting order correct for your
|
---|
| 49 | country;</para></listitem>
|
---|
| 50 | <listitem><para>good default paper size;</para></listitem>
|
---|
| 51 | <listitem><para>correct formatting of monetary, time and date
|
---|
| 52 | values.</para></listitem>
|
---|
| 53 | </itemizedlist>
|
---|
| 54 |
|
---|
| 55 | <para>This script also sets the INPUTRC environment variable that makes
|
---|
| 56 | <application>Bash</application> and <application>Readline</application> use
|
---|
| 57 | the <filename>/etc/inputrc</filename> file we created earlier.</para>
|
---|
| 58 |
|
---|
| 59 | <para>Replace <replaceable>[ll]</replaceable> below with the
|
---|
[f67f5cf] | 60 | two-letter code for your language (e.g., <quote>en</quote>) and
|
---|
| 61 | <replaceable>[CC]</replaceable> with the two-letter code for your country
|
---|
| 62 | (e.g., <quote>GB</quote>). Also you may need to specify
|
---|
[b32e803] | 63 | (and this is actually the preferred form) your
|
---|
[181a690] | 64 | character encoding (e.g. <quote>iso8859-1</quote>) after a dot
|
---|
| 65 | (so that the result is <quote>en_GB.iso8859-1</quote>).
|
---|
[b32e803] | 66 | Issue the following command for more information:</para>
|
---|
| 67 |
|
---|
| 68 | <screen><userinput>man 3 setlocale</userinput></screen>
|
---|
| 69 |
|
---|
[f67f5cf] | 70 | <para>The list of all locales supported by Glibc can be obtained by running
|
---|
[b32e803] | 71 | the following command:</para>
|
---|
| 72 |
|
---|
| 73 | <screen><userinput>locale -a</userinput></screen>
|
---|
| 74 |
|
---|
| 75 | <para>Now, when you are sure about your locale settings, create the
|
---|
| 76 | <filename>/etc/profile</filename> file:</para>
|
---|
[f67f5cf] | 77 |
|
---|
[b32e803] | 78 | <screen><userinput>cat > /etc/profile << "EOF"
|
---|
| 79 | # Begin /etc/profile
|
---|
| 80 |
|
---|
[f67f5cf] | 81 | export LC_ALL=<replaceable>[ll]</replaceable>_<replaceable>[CC]</replaceable>
|
---|
| 82 | export LANG=<replaceable>[ll]</replaceable>_<replaceable>[CC]</replaceable>
|
---|
[b32e803] | 83 | export INPUTRC=/etc/inputrc
|
---|
| 84 |
|
---|
| 85 | # End /etc/profile
|
---|
| 86 | EOF</userinput></screen>
|
---|
| 87 |
|
---|
[181a690] | 88 | <note><para>The <quote>C</quote> (default) and <quote>en_US</quote>
|
---|
[a734e03] | 89 | (the recommended one for US English users) locales are
|
---|
[181a690] | 90 | different.</para></note>
|
---|
| 91 |
|
---|
[b32e803] | 92 | <para>Setting the keyboard layout,
|
---|
| 93 | the screen font and the locale-related environment variables
|
---|
| 94 | are the only internationalization steps needed to support
|
---|
| 95 | locales that use ordinary single-byte encodings and left-to-right
|
---|
| 96 | writing direction. More complex cases (including UTF-8 based locales)
|
---|
| 97 | require additional steps and additional patches because many applications
|
---|
| 98 | tend to break in such conditions. Because of too little educational
|
---|
| 99 | value for a typical reader, these steps and patches are not included
|
---|
| 100 | in the LFS book and such locales are not supported by LFS in any way.
|
---|
| 101 | </para>
|
---|
| 102 | </sect1>
|
---|