profile.xml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
  3. <!ENTITY % general-entities SYSTEM "../general.ent">
  4. %general-entities;
  5. ]>
  6. <sect1 id="ch-scripts-profile">
  7. <title>The Bash Shell Startup Files</title>
  8. <?dbhtml filename="profile.html"?>
  9. <indexterm zone="ch-scripts-profile"><primary sortas="e-/etc/profile">/etc/profile</primary></indexterm>
  10. <para>The shell program <command>/bin/bash</command> (hereafter
  11. referred to as <quote>the shell</quote>) uses a collection of startup
  12. files to help create an environment to run in. Each file has a
  13. specific use and may affect login and interactive environments
  14. differently. The files in the <filename
  15. class="directory">/etc</filename> directory provide global settings.
  16. If an equivalent file exists in the home directory, it may override
  17. the global settings.</para>
  18. <para>An interactive login shell is started after a successful login,
  19. using <command>/bin/login</command>, by reading the
  20. <filename>/etc/passwd</filename> file. An interactive non-login shell
  21. is started at the command-line (e.g.,
  22. <prompt>[prompt]$</prompt><command>/bin/bash</command>). A
  23. non-interactive shell is usually present when a shell script is
  24. running. It is non-interactive because it is processing a script and
  25. not waiting for user input between commands.</para>
  26. <para>For more information, see <command>info bash</command> - Nodes:
  27. Bash Startup Files and Interactive Shells.</para>
  28. <para>The files <filename>/etc/profile</filename> and
  29. <filename>~/.bash_profile</filename> are read when the shell is
  30. invoked as an interactive login shell.</para>
  31. <para>A base <filename>/etc/profile</filename> below sets some
  32. environment variables necessary for native language support. Setting
  33. them properly results in:</para>
  34. <itemizedlist>
  35. <listitem><para>The output of programs translated into the native
  36. language</para></listitem>
  37. <listitem><para>Correct classification of characters into letters,
  38. digits and other classes. This is necessary for Bash to properly
  39. accept non-ASCII characters in command lines in non-English
  40. locales</para></listitem>
  41. <listitem><para>The correct alphabetical sorting order for the
  42. country</para></listitem>
  43. <listitem><para>Appropriate default paper size</para></listitem>
  44. <listitem><para>Correct formatting of monetary, time, and date
  45. values</para></listitem>
  46. </itemizedlist>
  47. <para>This script also sets the <envar>INPUTRC</envar>
  48. environment variable that makes <application>Bash</application> and
  49. <application>Readline</application> use the
  50. <filename>/etc/inputrc</filename> file created earlier.</para>
  51. <para>Replace <replaceable>[ll]</replaceable> below with the
  52. two-letter code for the desired language (e.g., <quote>en</quote>) and
  53. <replaceable>[CC]</replaceable> with the two-letter code for the
  54. appropriate country (e.g., <quote>GB</quote>).
  55. <replaceable>[charmap]</replaceable> should be replaced with the
  56. canonical charmap for your chosen locale.</para>
  57. <para>The list of all locales supported by Glibc can be obtained by running
  58. the following command:</para>
  59. <screen><userinput>locale -a</userinput></screen>
  60. <para>Locales can have a number of synonyms, e.g. <quote>ISO-8859-1</quote> is
  61. also referred to as <quote>iso8859-1</quote> and <quote>iso88591</quote>.
  62. Some applications cannot handle the various synonyms correctly, so it is safest
  63. to choose the canonical name for a particular locale. To determine the
  64. canonical name, run the following command, where
  65. <replaceable>[locale name]</replaceable> is the output given by
  66. <command>locale -a</command> for your preferred locale
  67. (<quote>en_GB.iso88591</quote> in our example).</para>
  68. <screen><userinput>LC_ALL=<replaceable>[locale name]</replaceable> locale charmap</userinput></screen>
  69. <para>For the <quote>en_GB.iso88591</quote> locale, the above command
  70. will print:</para>
  71. <screen>ISO-8859-1</screen>
  72. <para>This results in in a final locale setting of <quote>en_GB.ISO-8859-1</quote>.</para>
  73. <para>Once the proper locale settings have been determined, create the
  74. <filename>/etc/profile</filename> file:</para>
  75. <screen><userinput>cat &gt; /etc/profile &lt;&lt; "EOF"
  76. <literal># Begin /etc/profile
  77. export LANG=<replaceable>[ll]</replaceable>_<replaceable>[CC]</replaceable>.<replaceable>[charmap]</replaceable>
  78. export INPUTRC=/etc/inputrc
  79. # End /etc/profile</literal>
  80. EOF</userinput></screen>
  81. <note><para>The <quote>C</quote> (default) and <quote>en_US</quote>
  82. (the recommended one for United States English users) locales are
  83. different.</para></note>
  84. <para>Setting the keyboard layout, screen font, and
  85. locale-related environment variables are the only internationalization
  86. steps needed to support locales that use ordinary single-byte
  87. encodings and left-to-right writing direction. More complex cases
  88. (including UTF-8 based locales) require additional steps and
  89. additional patches because many applications tend to not work properly
  90. under such conditions. These steps and patches are not included in
  91. the LFS book and such locales are not supported by LFS in any
  92. way.</para>
  93. </sect1>