source: chapter07/profile.xml@ 1375d26

Last change on this file since 1375d26 was a811dff0, checked in by Matthew Burgess <matthew@…>, 20 years ago
  • (chapter07/*.xml) RELAX NG validation fixes

git-svn-id: http://svn.linuxfromscratch.org/LFS/branches/LFS-RNG/BOOK@4351 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

  • Property mode set to 100644
File size: 4.4 KB
Line 
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<info><title>The Bash Shell Startup Files</title></info>
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
14referred to as just <quote>the shell</quote>) uses a collection of startup files to
15help create an environment to run in. Each file has a specific use and
16may affect login and interactive environments differently. The files in
17the <filename class="directory">/etc</filename> directory generally provide global
18settings. If an equivalent file exists in your home directory it may
19override 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
25interactive non-login shell is started at the command-line (e.g.,
26<prompt>[prompt]$</prompt><command>/bin/bash</command>). A non-interactive
27shell is usually present when a shell script is running. It is non-interactive
28because it is processing a script and not waiting for user input between
29commands.</para>
30
31<para>For more information see <command>info bash</command> --
32<emphasis role="strong">Nodes: Bash Startup Files and Interactive
33Shells.</emphasis></para>
34
35<para>The files <filename>/etc/profile</filename> and
36<filename>~/.bash_profile</filename> are read when the shell is invoked
37as an interactive login shell.</para>
38
39<para>A base <filename>/etc/profile</filename> created below sets some
40environment variables necessary for native language support. By setting them
41properly, you get:
42</para>
43<itemizedlist>
44<listitem><para>the output of programs translated into your native
45language;</para></listitem>
46<listitem><para>correct classification of characters into letters, digits and
47other classes - this is necessary for Bash to accept non-ASCII characters
48in command lines properly in non-English locales;</para></listitem>
49<listitem><para>the alphabetical sorting order correct for your
50country;</para></listitem>
51<listitem><para>good default paper size;</para></listitem>
52<listitem><para>correct formatting of monetary, time and date
53values.</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
58the <filename>/etc/inputrc</filename> file we created earlier.</para>
59
60<para>Replace <replaceable>[ll]</replaceable> below with the
61two-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
65character encoding (e.g. <quote>iso8859-1</quote>) after a dot
66(so that the result is <quote>en_GB.iso8859-1</quote>).
67Issue 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
72the 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 &gt; /etc/profile &lt;&lt; "EOF"
80# Begin /etc/profile
81
82export LC_ALL=<replaceable>[ll]</replaceable>_<replaceable>[CC]</replaceable>
83export LANG=<replaceable>[ll]</replaceable>_<replaceable>[CC]</replaceable>
84export INPUTRC=/etc/inputrc
85
86# End /etc/profile
87EOF</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
91different.</para></note>
92
93<para>Setting the keyboard layout,
94the screen font and the locale-related environment variables
95are the only internationalization steps needed to support
96locales that use ordinary single-byte encodings and left-to-right
97writing direction. More complex cases (including UTF-8 based locales)
98require additional steps and additional patches because many applications
99tend to break in such conditions. Because of too little educational
100value for a typical reader, these steps and patches are not included
101in the LFS book and such locales are not supported by LFS in any way.
102</para>
103</section>
Note: See TracBrowser for help on using the repository browser.