Add an optional modification to theh build procedure for ninja to allow use the
[linux_from_scratch.git] / chapter07 / profile.xml
blob104365f417e9b966e8baa0bd20412f137de469da
1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3   "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
4   <!ENTITY % general-entities SYSTEM "../general.ent">
5   %general-entities;
6 ]>
8 <sect1 id="ch-scripts-profile" revision="sysv">
9   <?dbhtml filename="profile.html"?>
11   <title>The Bash Shell Startup Files</title>
13   <indexterm zone="ch-scripts-profile">
14     <primary sortas="e-/etc/profile">/etc/profile</primary>
15   </indexterm>
17   <para>The shell program <command>/bin/bash</command> (hereafter referred to
18   as <quote>the shell</quote>) uses a collection of startup files to help
19   create an environment to run in. Each file has a specific use and may affect
20   login and interactive environments differently. The files in the <filename
21   class="directory">/etc</filename> directory provide global settings. If an
22   equivalent file exists in the home directory, it may override the global
23   settings.</para>
25   <para>An interactive login shell is started after a successful login, using
26   <command>/bin/login</command>, by reading the <filename>/etc/passwd</filename>
27   file. An interactive non-login shell is started at the command-line (e.g.,
28   <prompt>[prompt]$</prompt><command>/bin/bash</command>). A non-interactive
29   shell is usually present when a shell script is running. It is non-interactive
30   because it is processing a script and not waiting for user input between
31   commands.</para>
33   <para>For more information, see <command>info bash</command> under the
34   <emphasis>Bash Startup Files and Interactive Shells</emphasis> section.</para>
36   <para>The files <filename>/etc/profile</filename> and
37   <filename>~/.bash_profile</filename> are read when the shell is
38   invoked as an interactive login shell.</para>
40   <para>The base <filename>/etc/profile</filename> below sets some
41   environment variables necessary for native language support. Setting
42   them properly results in:</para>
44   <itemizedlist>
45     <listitem>
46       <para>The output of programs translated into the native language</para>
47     </listitem>
48     <listitem>
49       <para>Correct classification of characters into letters, digits and other
50       classes. This is necessary for <command>bash</command> to properly accept
51       non-ASCII characters in command lines in non-English locales</para>
52     </listitem>
53     <listitem>
54       <para>The correct alphabetical sorting order for the country</para>
55     </listitem>
56     <listitem>
57       <para>Appropriate default paper size</para>
58     </listitem>
59     <listitem>
60       <para>Correct formatting of monetary, time, and date values</para>
61     </listitem>
62   </itemizedlist>
64   <para>Replace <replaceable>&lt;ll&gt;</replaceable> below with the two-letter code
65   for the desired language (e.g., <quote>en</quote>) and
66   <replaceable>&lt;CC&gt;</replaceable> with the two-letter code for the appropriate
67   country (e.g., <quote>GB</quote>). <replaceable>&lt;charmap&gt;</replaceable> should
68   be replaced with the canonical charmap for your chosen locale. Optional
69   modifiers such as <quote>@euro</quote> may also be present.</para>
71   <para>The list of all locales supported by Glibc can be obtained by running
72   the following command:</para>
74 <screen role="nodump"><userinput>locale -a</userinput></screen>
76   <para>Charmaps can have a number of aliases, e.g., <quote>ISO-8859-1</quote>
77   is also referred to as <quote>iso8859-1</quote> and <quote>iso88591</quote>.
78   Some applications cannot handle the various synonyms correctly (e.g., require
79   that <quote>UTF-8</quote> is written as <quote>UTF-8</quote>, not
80   <quote>utf8</quote>), so it is safest in most
81   cases to choose the canonical name for a particular locale. To determine
82   the canonical name, run the following command, where <replaceable>&lt;locale
83   name&gt;</replaceable> is the output given by <command>locale -a</command> for
84   your preferred locale (<quote>en_GB.iso88591</quote> in our example).</para>
86 <screen role="nodump"><userinput>LC_ALL=<replaceable>&lt;locale name&gt;</replaceable> locale charmap</userinput></screen>
88   <para>For the <quote>en_GB.iso88591</quote> locale, the above command
89   will print:</para>
91 <screen><computeroutput>ISO-8859-1</computeroutput></screen>
93   <para>This results in a final locale setting of <quote>en_GB.ISO-8859-1</quote>.
94   It is important that the locale found using the heuristic above is tested prior
95   to it being added to the Bash startup files:</para>
97 <screen role="nodump"><userinput>LC_ALL=&lt;locale name&gt; locale language
98 LC_ALL=&lt;locale name&gt; locale charmap
99 LC_ALL=&lt;locale name&gt; locale int_curr_symbol
100 LC_ALL=&lt;locale name&gt; locale int_prefix</userinput></screen>
102   <para>The above commands should print the language name, the character
103   encoding used by the locale, the local currency, and the prefix to dial
104   before the telephone number in order to get into the country. If any of the
105   commands above fail with a message similar to the one shown below, this means
106   that your locale was either not installed in Chapter&nbsp;6 or is not supported by
107   the default installation of Glibc.</para>
109 <screen><computeroutput>locale: Cannot set LC_* to default locale: No such file or directory</computeroutput></screen>
111   <para>If this happens, you should either install the desired locale using the
112   <command>localedef</command> command, or consider choosing a different locale.
113   Further instructions assume that there are no such error messages from
114   Glibc.</para>
116   <!-- FIXME: the xlib example will became obsolete real soon -->
117   <para>Some packages beyond LFS may also lack support for your chosen locale. One
118   example is the X library (part of the X Window System), which outputs the
119   following error message if the locale does not exactly match one of the character
120   map names in its internal files:</para>
122 <screen><computeroutput>Warning: locale not supported by Xlib, locale set to C</computeroutput></screen>
124   <para>In several cases Xlib expects that the character map will be listed in
125   uppercase notation with canonical dashes. For instance, "ISO-8859-1" rather
126   than "iso88591". It is also  possible to find an appropriate specification by
127   removing the charmap part of the locale specification.  This can be checked
128   by running the <command>locale charmap</command> command in both locales.
129   For example, one would have to change "de_DE.ISO-8859-15@euro" to
130   "de_DE@euro" in order to get this locale recognized by Xlib.</para>
132   <para>Other packages can also function incorrectly (but may not necessarily
133   display any error messages) if the locale name does not meet their expectations.
134   In those cases, investigating how other Linux distributions support your locale
135   might provide some useful information.</para>
137   <para>Once the proper locale settings have been determined, create the
138   <filename>/etc/profile</filename> file:</para>
140 <screen><userinput>cat &gt; /etc/profile &lt;&lt; "EOF"
141 <literal># Begin /etc/profile
143 export LANG=<replaceable>&lt;ll&gt;_&lt;CC&gt;.&lt;charmap&gt;&lt;@modifiers&gt;</replaceable>
145 # End /etc/profile</literal>
146 EOF</userinput></screen>
148   <para>The <quote>C</quote> (default) and <quote>en_US</quote> (the recommended
149   one for United States English users) locales are different. <quote>C</quote>
150   uses the US-ASCII 7-bit character set, and treats bytes with the high bit set
151   as invalid characters. That's why, e.g., the <command>ls</command> command
152   substitutes them with question marks in that locale. Also, an attempt to send
153   mail with such characters from Mutt or Pine results in non-RFC-conforming
154   messages being sent (the charset in the outgoing mail is indicated as <quote>unknown
155   8-bit</quote>). So you can use the <quote>C</quote> locale only if you are sure that
156   you will never need 8-bit characters.</para>
158   <para>UTF-8 based locales are not supported well by some programs.
159   Work is in progress to document and, if possible, fix such problems, see
160   <ulink url="&blfs-book;introduction/locale-issues.html"/>.</para>
162 </sect1>