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