source: chapter09/profile.xml@ 8ccf082a

multilib xry111/multilib
Last change on this file since 8ccf082a was 360fdfca, checked in by Pierre Labastie <pierre.labastie@…>, 8 months ago

Fix punctuation in quotes, and quote signs

  • period and comma inside quotes
  • " to <quote>
  • some " to <literal> when it is a var value
  • Property mode set to 100644
File size: 7.0 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
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]>
7
8<sect1 id="ch-config-profile" revision="sysv">
9 <?dbhtml filename="profile.html"?>
10
11 <title>The Bash Shell Startup Files</title>
12
13 <indexterm zone="ch-config-profile">
14 <primary sortas="e-/etc/profile">/etc/profile</primary>
15 </indexterm>
16
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 the 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
22 equivalent files exist in the home directory, they may override the global
23 settings.</para>
24
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>
32
33<para>For more information, see the <emphasis>Bash Startup Files</emphasis> and
34 <emphasis>Interactive Shells</emphasis> sections in the <emphasis>Bash
35 Features</emphasis> chapter of the Bash info pages (<command>info bash</command>).</para>
36
37 <para>The files <filename>/etc/profile</filename> and
38 <filename>~/.bash_profile</filename> are read when the shell is
39 invoked as an interactive login shell.</para>
40
41 <para>The base <filename>/etc/profile</filename> below sets some
42 environment variables necessary for native language support. Setting
43 them properly results in:</para>
44
45 <itemizedlist>
46 <listitem>
47 <para>The output of programs translated into the native language</para>
48 </listitem>
49 <listitem>
50 <para>Correct classification of characters into letters, digits and other
51 classes. This is necessary for <command>bash</command> to properly accept
52 non-ASCII characters in command lines in non-English locales</para>
53 </listitem>
54 <listitem>
55 <para>The correct alphabetical sorting order for the country</para>
56 </listitem>
57 <listitem>
58 <para>Appropriate default paper size</para>
59 </listitem>
60 <listitem>
61 <para>Correct formatting of monetary, time, and date values</para>
62 </listitem>
63 </itemizedlist>
64
65 <para>Replace <replaceable>&lt;ll&gt;</replaceable> below with the two-letter code
66 for the desired language (e.g., <quote>en</quote>) and
67 <replaceable>&lt;CC&gt;</replaceable> with the two-letter code for the appropriate
68 country (e.g., <quote>GB</quote>). <replaceable>&lt;charmap&gt;</replaceable> should
69 be replaced with the canonical charmap for your chosen locale. Optional
70 modifiers such as <quote>@euro</quote> may also be present.</para>
71
72 <para>The list of all locales supported by Glibc can be obtained by running
73 the following command:</para>
74
75<screen role="nodump"><userinput>locale -a</userinput></screen>
76
77 <para>Charmaps can have a number of aliases, e.g., <quote>ISO-8859-1</quote>
78 is also referred to as <quote>iso8859-1</quote> and <quote>iso88591.</quote>
79 Some applications cannot handle the various synonyms correctly (e.g., require
80 that <quote>UTF-8</quote> is written as <literal>UTF-8</literal>, not
81 <literal>utf8</literal>), so it is safest in most
82 cases to choose the canonical name for a particular locale. To determine
83 the canonical name, run the following command, where <replaceable>&lt;locale
84 name&gt;</replaceable> is the output given by <command>locale -a</command> for
85 your preferred locale (<quote>en_GB.iso88591</quote> in our example).</para>
86
87<screen role="nodump"><userinput>LC_ALL=<replaceable>&lt;locale name&gt;</replaceable> locale charmap</userinput></screen>
88
89 <para>For the <quote>en_GB.iso88591</quote> locale, the above command
90 will print:</para>
91
92<screen><computeroutput>ISO-8859-1</computeroutput></screen>
93
94 <para>This results in a final locale setting of <literal>en_GB.ISO-8859-1</literal>.
95 It is important that the locale found using the heuristic above is tested before
96 it is added to the Bash startup files:</para>
97
98<screen role="nodump"><userinput>LC_ALL=&lt;locale name&gt; locale language
99LC_ALL=&lt;locale name&gt; locale charmap
100LC_ALL=&lt;locale name&gt; locale int_curr_symbol
101LC_ALL=&lt;locale name&gt; locale int_prefix</userinput></screen>
102
103 <para>The above commands should print the language name, the character
104 encoding used by the locale, the local currency, and the prefix to dial
105 before the telephone number in order to get into the country. If any of the
106 commands above fail with a message similar to the one shown below, this means
107 that your locale was either not installed in <xref linkend="ch-system-glibc"/>
108 or is not supported by the default installation of Glibc.</para>
109
110<screen><computeroutput>locale: Cannot set LC_* to default locale: No such file or directory</computeroutput></screen>
111
112 <para>If this happens, you should either install the desired locale using the
113 <command>localedef</command> command, or consider choosing a different locale.
114 Further instructions assume that there are no such error messages from
115 Glibc.</para>
116
117 <para>Other packages may also function incorrectly (but will not necessarily
118 display any error messages) if the locale name does not meet their expectations.
119 In such cases, investigating how other Linux distributions support your locale
120 might provide some useful information.</para>
121
122 <para>Once the proper locale settings have been determined, create the
123 <filename>/etc/profile</filename> file:</para>
124
125<screen><userinput>cat &gt; /etc/profile &lt;&lt; "EOF"
126<literal># Begin /etc/profile
127
128export LANG=<replaceable>&lt;ll&gt;_&lt;CC&gt;.&lt;charmap&gt;&lt;@modifiers&gt;</replaceable>
129
130# End /etc/profile</literal>
131EOF</userinput></screen>
132
133 <para>The <quote>C</quote> (default) and <quote>en_US.utf8</quote> (the recommended
134 one for United States English users) locales are different. <quote>C</quote>
135 uses the US-ASCII 7-bit character set, and treats bytes with the high-order bit set
136 <quote>on</quote> as invalid characters. That's why, e.g., the <command>ls</command> command
137 displays them as question marks in that locale. Also, an attempt to send
138 mail with such characters from Mutt or Pine results in non-RFC-conforming
139 messages being sent (the charset in the outgoing mail is indicated as <quote>unknown
140 8-bit</quote>). So you can only use the <quote>C</quote> locale if you are sure
141 you will never need 8-bit characters.</para>
142
143 <para>UTF-8 based locales are not supported well by some programs.
144 Work is in progress to document and, if possible, fix such problems. See
145 <ulink url="&blfs-book;introduction/locale-issues.html"/>.</para>
146
147</sect1>
Note: See TracBrowser for help on using the repository browser.