source: chapter09/profile.xml@ 0d80918a

12.1 12.1-rc1 12.2 12.2-rc1 multilib trunk xry111/arm64 xry111/clfs-ng xry111/loongarch xry111/loongarch-12.1 xry111/loongarch-12.2 xry111/mips64el xry111/multilib xry111/update-glibc
Last change on this file since 0d80918a 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
RevLine 
[7152faa]1<?xml version="1.0" encoding="UTF-8"?>
[b06ca36]2<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
[b32e803]4 <!ENTITY % general-entities SYSTEM "../general.ent">
5 %general-entities;
6]>
[d781ffb]7
[afcfd74]8<sect1 id="ch-config-profile" revision="sysv">
[d781ffb]9 <?dbhtml filename="profile.html"?>
10
11 <title>The Bash Shell Startup Files</title>
12
[afcfd74]13 <indexterm zone="ch-config-profile">
[d781ffb]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
[d8ec0ed]19 create the environment to run in. Each file has a specific use and may affect
[d781ffb]20 login and interactive environments differently. The files in the <filename
[d8ec0ed]21 class="directory">/etc</filename> directory provide global settings. If
22 equivalent files exist in the home directory, they may override the global
[d781ffb]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
[d8ec0ed]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>
[d781ffb]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
[0090db5]65 <para>Replace <replaceable>&lt;ll&gt;</replaceable> below with the two-letter code
[d781ffb]66 for the desired language (e.g., <quote>en</quote>) and
[0090db5]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
[fa21b3d]69 be replaced with the canonical charmap for your chosen locale. Optional
70 modifiers such as <quote>@euro</quote> may also be present.</para>
[d781ffb]71
72 <para>The list of all locales supported by Glibc can be obtained by running
73 the following command:</para>
[81fd230]74
[0ebe9fa4]75<screen role="nodump"><userinput>locale -a</userinput></screen>
[81fd230]76
[fa21b3d]77 <para>Charmaps can have a number of aliases, e.g., <quote>ISO-8859-1</quote>
[360fdfca]78 is also referred to as <quote>iso8859-1</quote> and <quote>iso88591.</quote>
[fa21b3d]79 Some applications cannot handle the various synonyms correctly (e.g., require
[360fdfca]80 that <quote>UTF-8</quote> is written as <literal>UTF-8</literal>, not
81 <literal>utf8</literal>), so it is safest in most
[fa21b3d]82 cases to choose the canonical name for a particular locale. To determine
[0090db5]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
[d781ffb]85 your preferred locale (<quote>en_GB.iso88591</quote> in our example).</para>
[768efb56]86
[0090db5]87<screen role="nodump"><userinput>LC_ALL=<replaceable>&lt;locale name&gt;</replaceable> locale charmap</userinput></screen>
[768efb56]88
[d781ffb]89 <para>For the <quote>en_GB.iso88591</quote> locale, the above command
90 will print:</para>
[768efb56]91
[d781ffb]92<screen><computeroutput>ISO-8859-1</computeroutput></screen>
[768efb56]93
[360fdfca]94 <para>This results in a final locale setting of <literal>en_GB.ISO-8859-1</literal>.
[d8ec0ed]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>
[c45b780]97
[a85d4b9]98<screen role="nodump"><userinput>LC_ALL=&lt;locale name&gt; locale language
[0090db5]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>
[c45b780]102
[3db5b78]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
[d781ffb]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
[c34b4fb]107 that your locale was either not installed in <xref linkend="ch-system-glibc"/>
[a3d0817]108 or is not supported by the default installation of Glibc.</para>
[c45b780]109
[ac1d807]110<screen><computeroutput>locale: Cannot set LC_* to default locale: No such file or directory</computeroutput></screen>
[c45b780]111
[d781ffb]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>
[c45b780]116
[d8ec0ed]117 <para>Other packages may also function incorrectly (but will not necessarily
[d781ffb]118 display any error messages) if the locale name does not meet their expectations.
[d8ec0ed]119 In such cases, investigating how other Linux distributions support your locale
[d781ffb]120 might provide some useful information.</para>
[768efb56]121
[d781ffb]122 <para>Once the proper locale settings have been determined, create the
123 <filename>/etc/profile</filename> file:</para>
[f67f5cf]124
[b32e803]125<screen><userinput>cat &gt; /etc/profile &lt;&lt; "EOF"
[d72e04a]126<literal># Begin /etc/profile
[b32e803]127
[e56d9dc]128export LANG=<replaceable>&lt;ll&gt;_&lt;CC&gt;.&lt;charmap&gt;&lt;@modifiers&gt;</replaceable>
[b32e803]129
[d72e04a]130# End /etc/profile</literal>
[b32e803]131EOF</userinput></screen>
132
[a3d0817]133 <para>The <quote>C</quote> (default) and <quote>en_US.utf8</quote> (the recommended
[fa21b3d]134 one for United States English users) locales are different. <quote>C</quote>
[d8ec0ed]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
[fa21b3d]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
[d8ec0ed]140 8-bit</quote>). So you can only use the <quote>C</quote> locale if you are sure
[fa21b3d]141 you will never need 8-bit characters.</para>
142
[b3eb525]143 <para>UTF-8 based locales are not supported well by some programs.
[d8ec0ed]144 Work is in progress to document and, if possible, fix such problems. See
[0ee07e5]145 <ulink url="&blfs-book;introduction/locale-issues.html"/>.</para>
[94aa6621]146
[b32e803]147</sect1>
Note: See TracBrowser for help on using the repository browser.