Changeset 2753b70b


Ignore:
Timestamp:
05/12/2005 09:05:36 PM (19 years ago)
Author:
Manuel Canales Esparcia <manuel@…>
Branches:
10.0, 10.1, 11.0, 11.1, 11.2, 11.3, 12.0, 12.1, 6.1, 6.2, 6.2.0, 6.2.0-rc1, 6.2.0-rc2, 6.3, 6.3-rc1, 6.3-rc2, 6.3-rc3, 7.10, 7.4, 7.5, 7.6, 7.6-blfs, 7.6-systemd, 7.7, 7.8, 7.9, 8.0, 8.1, 8.2, 8.3, 8.4, 9.0, 9.1, basic, bdubbs/svn, elogind, gnome, kde5-13430, kde5-14269, kde5-14686, kea, ken/TL2024, ken/inkscape-core-mods, ken/tuningfonts, krejzi/svn, lazarus, lxqt, nosym, perl-modules, plabs/newcss, plabs/python-mods, python3.11, qt5new, rahul/power-profiles-daemon, renodr/vulkan-addition, systemd-11177, systemd-13485, trunk, upgradedb, xry111/intltool, xry111/llvm18, xry111/soup3, xry111/test-20220226, xry111/xf86-video-removal
Children:
5a1ffdd
Parents:
07ac9895
Message:

Tagged profile.xml

git-svn-id: svn://svn.linuxfromscratch.org/BLFS/trunk/BOOK@4176 af4574ff-66df-0310-9fd7-8a98e5e911e0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • postlfs/config/profile.xml

    r07ac9895 r2753b70b  
    77
    88<sect1 id="postlfs-config-profile" xreflabel="The Bash Shell Startup Files">
    9 <sect1info>
    10 <othername>$LastChangedBy$</othername>
    11 <date>$Date$</date>
    12 </sect1info>
    13 <?dbhtml filename="profile.html"?>
    14 <title>The Bash Shell Startup Files</title>
    15 
    16 <para>The shell program <filename>/bin/bash</filename> (hereafter
    17 referred to as just "the shell") uses a collection of startup files to
    18 help create an environment.  Each file has a specific use and
    19 may affect login and interactive environments differently.  The files in
    20 the <filename class="directory">/etc</filename> directory generally provide
    21 global settings. If an equivalent file exists in your home directory it may
    22 override the global settings.
    23 </para>
    24 
    25 <para>An interactive login shell is started after a successful login, using
    26 <filename>/bin/login</filename>, by reading the <filename>/etc/passwd</filename>
    27 file.  This shell invocation normally reads <filename>/etc/profile</filename>
    28 and its private equivalent <filename>~/.bash_profile</filename> upon
    29 startup.</para>
    30 
    31 <para>An interactive non-login shell is normally started at the command-line
    32 (e.g.,  <prompt>[prompt]$</prompt><command>/bin/bash</command>) or by the
    33 <command>/bin/su</command> command.  An interactive non-login shell is also
    34 started with a terminal program such as <command>xterm</command> or
    35 <command>konsole</command> from within a graphical environment. This type of
    36 shell invocation normally copies the parent environment and then reads the
    37 user's <filename>~/.bashrc</filename> file for additional startup configuration
    38 instructions.</para>
    39 
    40 <para>A non-interactive shell is usually present when a shell script is
    41 running.  It is non-interactive because it is processing a script and not
    42 waiting for user input between commands. For these shell invocations, only
    43 the environment inherited from the parent shell is used.</para>
    44 
    45 <para> The file <filename>~/.bash_logout</filename> is not used for an
    46 invocation of the shell.  It is read and executed when a user exits from an
    47 interactive login shell.</para>
    48 
    49 <para>To the standard files, <filename>/etc/bashrc</filename> is called from
    50 the user's <filename>~/.bashrc</filename> for system wide initialization of
    51 non-login shells.</para>
    52 
    53 <para>For more information see <command>info bash</command> --
    54 <emphasis role="strong">Nodes: Bash Startup Files and Interactive
    55 Shells.</emphasis></para>
    56 
    57 <sect2 id="etc-profile-profile">
    58 <title><filename>/etc/profile</filename></title>
    59 <indexterm zone="postlfs-config-profile etc-profile-profile">
    60 <primary sortas="e-etc-profile">/etc/profile</primary>
    61 </indexterm>
    62 
    63 <para>Here is a base <filename>/etc/profile</filename>. This file starts by
    64 setting up some helper functions and some basic parameters.  It specifies some
    65 <filename>bash</filename> history parameters and, for security purposes,
    66 disables keeping a permanent history file for the root user.  It also sets a
    67 default user prompt.  It then calls small, single purpose scripts in the
    68 <filename class='directory'>/etc/profile.d</filename> directory to provide most
    69 initialization.  </para>
    70 
    71 <para>For more information on the escape sequences you can use for your prompt
    72 (e.g.,  the <envar>PS1</envar> environment variable) see <command>info
    73 bash</command> -- <emphasis role="strong">Node: Printing a
    74 Prompt.</emphasis></para>
    75 
    76 <screen><userinput><command>cat &gt; /etc/profile &lt;&lt; "EOF"</command>
    77 # Begin /etc/profile
     9  <?dbhtml filename="profile.html"?>
     10
     11  <sect1info>
     12    <othername>$LastChangedBy$</othername>
     13    <date>$Date$</date>
     14  </sect1info>
     15
     16  <title>The Bash Shell Startup Files</title>
     17
     18  <para>The shell program <filename>/bin/bash</filename> (hereafter
     19  referred to as just "the shell") uses a collection of startup files to
     20  help create an environment.  Each file has a specific use and
     21  may affect login and interactive environments differently.  The files in
     22  the <filename class="directory">/etc</filename> directory generally provide
     23  global settings. If an equivalent file exists in your home directory it may
     24  override the global settings.</para>
     25
     26  <para>An interactive login shell is started after a successful login, using
     27  <filename>/bin/login</filename>, by reading the <filename>/etc/passwd</filename>
     28  file.  This shell invocation normally reads <filename>/etc/profile</filename>
     29  and its private equivalent <filename>~/.bash_profile</filename> upon
     30  startup.</para>
     31
     32  <para>An interactive non-login shell is normally started at the command-line
     33  (e.g.,  <prompt>[prompt]$</prompt><command>/bin/bash</command>) or by the
     34  <command>/bin/su</command> command.  An interactive non-login shell is also
     35  started with a terminal program such as <command>xterm</command> or
     36  <command>konsole</command> from within a graphical environment. This type of
     37  shell invocation normally copies the parent environment and then reads the
     38  user's <filename>~/.bashrc</filename> file for additional startup configuration
     39  instructions.</para>
     40
     41  <para>A non-interactive shell is usually present when a shell script is
     42  running.  It is non-interactive because it is processing a script and not
     43  waiting for user input between commands. For these shell invocations, only
     44  the environment inherited from the parent shell is used.</para>
     45
     46  <para> The file <filename>~/.bash_logout</filename> is not used for an
     47  invocation of the shell.  It is read and executed when a user exits from an
     48  interactive login shell.</para>
     49
     50  <para>To the standard files, <filename>/etc/bashrc</filename> is called from
     51  the user's <filename>~/.bashrc</filename> for system wide initialization of
     52  non-login shells.</para>
     53
     54  <para>For more information see <command>info bash</command> --
     55  <emphasis role="strong">Nodes: Bash Startup Files and Interactive
     56  Shells.</emphasis></para>
     57
     58  <sect2 id="etc-profile-profile">
     59    <title>/etc/profile</title>
     60
     61    <indexterm zone="postlfs-config-profile etc-profile-profile">
     62      <primary sortas="e-etc-profile">/etc/profile</primary>
     63    </indexterm>
     64
     65    <para>Here is a base <filename>/etc/profile</filename>. This file starts by
     66    setting up some helper functions and some basic parameters.  It specifies some
     67    <filename>bash</filename> history parameters and, for security purposes,
     68    disables keeping a permanent history file for the <systemitem
     69    class="username">root</systemitem> user.  It also sets a
     70    default user prompt.  It then calls small, single purpose scripts in the
     71    <filename class='directory'>/etc/profile.d</filename> directory to provide most
     72    initialization.  </para>
     73
     74    <para>For more information on the escape sequences you can use for your prompt
     75    (e.g.,  the <envar>PS1</envar> environment variable) see <command>info
     76    bash</command> -- <emphasis role="strong">Node: Printing a
     77    Prompt.</emphasis></para>
     78
     79<screen role="root"><userinput>cat &gt; /etc/profile &lt;&lt; "EOF"
     80<literal># Begin /etc/profile
    7881# Written for Beyond Linux From Scratch
    7982# by James Robertson &lt;jameswrobertson@earthlink.net&gt;
     
    138141unset pathremove pathprepend pathappend
    139142
    140 # End /etc/profile
    141 <command>EOF</command></userinput></screen>
    142 
    143 <sect3 id="etc-profile.d"><title>The /etc/profile.d directory</title>
    144 <indexterm zone="postlfs-config-profile etc-profile.d">
    145 <primary sortas="e-etc-profile.d">/etc/profile.d</primary>
    146 </indexterm>
    147 
    148 <para>Now create the <filename class='directory'>/etc/profile.d</filename>
    149 directory, where the individual initialization scripts are placed.</para>
    150 
    151 <screen><userinput><command>install --directory --mode=0755 --owner=root --group=root /etc/profile.d</command></userinput></screen>
    152 </sect3>
    153 
    154 <sect3 id="etc-profile.d-dircolors.sh">
    155 <title><filename>/etc/profile.d/dircolors.sh</filename></title>
    156 <indexterm zone="postlfs-config-profile etc-profile.d-dircolors.sh">
    157 <primary
    158 sortas="e-etc-profile.d-dircolors.sh">/etc/profile.d/dircolors.sh</primary>
    159 </indexterm>
    160 
    161 <para>This script uses the <filename>~/.dircolors</filename> and
    162 <filename>/etc/dircolors</filename> files to control the colors of file names in a
    163 directory listing. They control colorized output of things like <command>ls
    164 --color</command>.  The explaination of how to initialize these files is at the
    165 end of this section.</para>
    166 
    167 <screen><userinput><command>cat &gt; /etc/profile.d/dircolors.sh &lt;&lt; "EOF"</command>
    168 # Setup for /bin/ls to support color, the alias is in /etc/bashrc.
     143# End /etc/profile</literal>
     144EOF</userinput></screen>
     145
     146    <sect3 id="etc-profile.d">
     147      <title>The /etc/profile.d Directory</title>
     148
     149      <indexterm zone="postlfs-config-profile etc-profile.d">
     150        <primary sortas="e-etc-profile.d">/etc/profile.d</primary>
     151      </indexterm>
     152
     153      <para>Now create the <filename class='directory'>/etc/profile.d</filename>
     154      directory, where the individual initialization scripts are placed.</para>
     155
     156<screen role="root"><userinput>install --directory --mode=0755 --owner=root --group=root /etc/profile.d</userinput></screen>
     157
     158    </sect3>
     159
     160    <sect3 id="etc-profile.d-dircolors.sh">
     161      <title>/etc/profile.d/dircolors.sh</title>
     162
     163      <indexterm zone="postlfs-config-profile etc-profile.d-dircolors.sh">
     164        <primary sortas="e-etc-profile.d-dircolors.sh">/etc/profile.d/dircolors.sh</primary>
     165      </indexterm>
     166
     167      <para>This script uses the <filename>~/.dircolors</filename> and
     168      <filename>/etc/dircolors</filename> files to control the colors of file names in a
     169      directory listing. They control colorized output of things like <command>ls
     170      --color</command>.  The explaination of how to initialize these files is at the
     171      end of this section.</para>
     172
     173<screen role="root"><userinput>cat &gt; /etc/profile.d/dircolors.sh &lt;&lt; "EOF"
     174<literal># Setup for /bin/ls to support color, the alias is in /etc/bashrc.
    169175if [ -f "/etc/dircolors" ] ; then
    170176        eval $(dircolors -b /etc/dircolors)
     
    174180        fi
    175181fi
    176 alias ls='ls --color=auto'
    177 <command>EOF</command></userinput></screen>
    178 </sect3>
    179 
    180 <sect3 id="extrapaths.sh">
    181 <title><filename>/etc/profile.d/extrapaths.sh</filename></title>
    182 <indexterm zone="postlfs-config-profile extrapaths.sh">
    183 <primary
    184 sortas="e-etc-profile.d-extrapaths.sh">/etc/profile.d/extrapaths.sh</primary>
    185 </indexterm>
    186 
    187 <para>This script adds several useful paths to the <envar>PATH</envar> and
    188 <envar>PKG_CONFIG_PATH</envar> environment variables.  If you want, you can
    189 uncomment the last section to put a dot at the end of your path. This will
    190 allow executables in the current working directory to be executed without
    191 specifiying a ./, however you are warned that this is generally considered a
    192 security hazard.</para>
    193  
    194 <screen><userinput><command>cat &gt; /etc/profile.d/extrapaths.sh &lt;&lt; "EOF"</command>
    195 if [ -d /usr/local/lib/pkgconfig ] ; then
     182alias ls='ls --color=auto'</literal>
     183EOF</userinput></screen>
     184
     185    </sect3>
     186
     187    <sect3 id="extrapaths.sh">
     188      <title>/etc/profile.d/extrapaths.sh</title>
     189
     190      <indexterm zone="postlfs-config-profile extrapaths.sh">
     191        <primary sortas="e-etc-profile.d-extrapaths.sh">/etc/profile.d/extrapaths.sh</primary>
     192      </indexterm>
     193
     194      <para>This script adds several useful paths to the <envar>PATH</envar> and
     195      <envar>PKG_CONFIG_PATH</envar> environment variables.  If you want, you
     196      can uncomment the last section to put a dot at the end of your path. This will
     197      allow executables in the current working directory to be executed without
     198      specifiying a ./, however you are warned that this is generally considered a
     199      security hazard.</para>
     200 
     201<screen role="root"><userinput>cat &gt; /etc/profile.d/extrapaths.sh &lt;&lt; "EOF"
     202<literal>if [ -d /usr/local/lib/pkgconfig ] ; then
    196203        pathappend /usr/local/lib/pkgconfig PKG_CONFIG_PATH
    197204fi
     
    213220#if [ $EUID -gt 99 ]; then
    214221#        pathappend .
    215 #fi
    216 <command>EOF</command></userinput></screen>
    217 </sect3>
    218 
    219 <sect3 id="readline.sh">
    220 <title><filename>/etc/profile.d/readline.sh</filename></title>
    221 <indexterm zone="postlfs-config-profile readline.sh">
    222 <primary
    223 sortas="e-etc-profile.d-readline.sh">/etc/profile.d/readline.sh</primary>
    224 </indexterm>
    225 
    226 <para>This script sets up the default <filename>inputrc</filename>
    227 configuration file. If the user does not have individual settings, it uses the
    228 global file.</para>
    229 
    230 <screen><userinput><command>cat &gt; /etc/profile.d/readline.sh &lt;&lt; "EOF"</command>
    231 # Setup the INPUTRC environment variable.
     222#fi</literal>
     223EOF</userinput></screen>
     224
     225    </sect3>
     226
     227    <sect3 id="readline.sh">
     228      <title>/etc/profile.d/readline.sh</title>
     229
     230      <indexterm zone="postlfs-config-profile readline.sh">
     231        <primary sortas="e-etc-profile.d-readline.sh">/etc/profile.d/readline.sh</primary>
     232      </indexterm>
     233
     234      <para>This script sets up the default <filename>inputrc</filename>
     235      configuration file. If the user does not have individual settings, it uses the
     236      global file.</para>
     237
     238<screen role="root"><userinput>cat &gt; /etc/profile.d/readline.sh &lt;&lt; "EOF"
     239<literal># Setup the INPUTRC environment variable.
    232240if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ] ; then
    233241        INPUTRC=/etc/inputrc
    234242fi
    235 export INPUTRC
    236 <command>EOF</command></userinput></screen>
    237 </sect3>
    238 
    239 <sect3 id="tinker-term.sh">
    240 <title><filename>/etc/profile.d/tinker-term.sh</filename></title>
    241 <indexterm zone="postlfs-config-profile tinker-term.sh">
    242 <primary
    243 sortas="e-etc-profile.d-tinker-term.sh">/etc/profile.d/tinker-term.sh</primary>
    244 </indexterm>
    245 
    246 <para>Some applications need a specific <envar>TERM</envar> setting to support
    247 color.</para>
    248 
    249 <screen><userinput><command>cat &gt; /etc/profile.d/tinker-term.sh &lt;&lt; "EOF"</command>
    250 # This will tinker with the value of TERM in order to convince certain
     243export INPUTRC</literal>
     244EOF</userinput></screen>
     245
     246    </sect3>
     247
     248    <sect3 id="tinker-term.sh">
     249      <title>/etc/profile.d/tinker-term.sh</title>
     250
     251      <indexterm zone="postlfs-config-profile tinker-term.sh">
     252        <primary sortas="e-etc-profile.d-tinker-term.sh">/etc/profile.d/tinker-term.sh</primary>
     253      </indexterm>
     254
     255      <para>Some applications need a specific <envar>TERM</envar> setting to
     256      support color.</para>
     257
     258<screen role="root"><userinput>cat &gt; /etc/profile.d/tinker-term.sh &lt;&lt; "EOF"
     259<literal># This will tinker with the value of TERM in order to convince certain
    251260# apps that we can, indeed, display color in their window.
    252261 
     
    257266if [ "$TERM" = "xterm" ]; then
    258267  export TERM=xterm-color
    259 fi
    260 <command>EOF</command></userinput></screen>
    261 </sect3>
    262 
    263 <sect3 id="umask.sh">
    264 <title><filename>/etc/profile.d/umask.sh</filename></title>
    265 <indexterm zone="postlfs-config-profile umask.sh">
    266 <primary
    267 sortas="e-etc-profile.d-umask.sh">/etc/profile.d/umask.sh</primary>
    268 </indexterm>
    269  
    270 <para>Setting the <command>umask</command> value is important for security.
    271 Here the default group write permissions are turned off for system users and when
    272 the user name and group name are not the same.</para>
    273 
    274 <screen><userinput><command>cat &gt; /etc/profile.d/umask.sh &lt;&lt; "EOF"</command>
    275 # By default we want the umask to get set.
     268fi</literal>
     269EOF</userinput></screen>
     270
     271    </sect3>
     272
     273    <sect3 id="umask.sh">
     274      <title>/etc/profile.d/umask.sh</title>
     275
     276      <indexterm zone="postlfs-config-profile umask.sh">
     277        <primary sortas="e-etc-profile.d-umask.sh">/etc/profile.d/umask.sh</primary>
     278      </indexterm>
     279 
     280      <para>Setting the <command>umask</command> value is important for security.
     281      Here the default group write permissions are turned off for system users and when
     282      the user name and group name are not the same.</para>
     283
     284<screen role="root"><userinput>cat &gt; /etc/profile.d/umask.sh &lt;&lt; "EOF"
     285<literal># By default we want the umask to get set.
    276286if [ "$(id -gn)" = "$(id -un)" -a $EUID -gt 99 ] ; then
    277287  umask 002
    278288else
    279289  umask 022
    280 fi
    281 <command>EOF</command></userinput></screen>
    282 </sect3>
    283 
    284 <sect3 id="X.sh">
    285 <title><filename>/etc/profile.d/X.sh</filename></title>
    286 <indexterm zone="postlfs-config-profile X.sh">
    287 <primary
    288 sortas="e-etc-profile.d-X.sh">/etc/profile.d/X.sh</primary>
    289 </indexterm>
    290 
    291 <para>If <application>X</application> is installed, the <envar>PATH</envar>
    292 and <envar>PKG_CONFIG_PATH</envar> variables are also updated.</para>
    293 
    294 <screen><userinput><command>cat &gt; /etc/profile.d/X.sh &lt;&lt; "EOF"</command>
    295 if [ -x /usr/X11R6/bin/X ]; then
     290fi</literal>
     291EOF</userinput></screen>
     292
     293    </sect3>
     294
     295    <sect3 id="X.sh">
     296      <title>/etc/profile.d/X.sh</title>
     297
     298      <indexterm zone="postlfs-config-profile X.sh">
     299        <primary sortas="e-etc-profile.d-X.sh">/etc/profile.d/X.sh</primary>
     300      </indexterm>
     301
     302      <para>If <application>X</application> is installed, the <envar>PATH</envar>
     303      and <envar>PKG_CONFIG_PATH</envar> variables are also updated.</para>
     304
     305<screen role="root"><userinput>cat &gt; /etc/profile.d/X.sh &lt;&lt; "EOF"
     306<literal>if [ -x /usr/X11R6/bin/X ]; then
    296307        pathappend /usr/X11R6/bin
    297308fi
    298309if [ -d /usr/X11R6/lib/pkgconfig ] ; then
    299310        pathappend /usr/X11R6/lib/pkgconfig PKG_CONFIG_PATH
    300 fi
    301 <command>EOF</command></userinput></screen>
    302 </sect3>
    303 
    304 <sect3 id="titlebars.sh">
    305 <title><filename>/etc/profile.d/xterm-titlebars.sh</filename></title>
    306 <indexterm zone="postlfs-config-profile titlebars.sh">
    307 <primary
    308 sortas="e-etc-profile.d-titlebars.sh">/etc/profile.d/titlebars.sh</primary>
    309 </indexterm>
    310 
    311 <para>This script shows an example of a different way of setting the prompt.
    312 The normal variable, <envar>PS1</envar>, is supplemented by
    313 <envar>PROMPT_COMMAND</envar>. If set, the value of
    314 <envar>PROMPT_COMMAND</envar> is executed as a command prior to issuing each
    315 primary prompt.</para>
    316  
    317 <screen><userinput><command>cat &gt; /etc/profile.d/xterm-titlebars.sh &lt;&lt; "EOF"</command>
    318 # The substring match ensures this works for "xterm" and "xterm-xfree86".
     311fi</literal>
     312EOF</userinput></screen>
     313
     314    </sect3>
     315
     316    <sect3 id="titlebars.sh">
     317      <title>/etc/profile.d/xterm-titlebars.sh</title>
     318
     319      <indexterm zone="postlfs-config-profile titlebars.sh">
     320        <primary sortas="e-etc-profile.d-titlebars.sh">/etc/profile.d/titlebars.sh</primary>
     321      </indexterm>
     322
     323      <para>This script shows an example of a different way of setting the prompt.
     324      The normal variable, <envar>PS1</envar>, is supplemented by
     325      <envar>PROMPT_COMMAND</envar>. If set, the value of
     326      <envar>PROMPT_COMMAND</envar> is executed as a command prior to
     327      issuing each primary prompt.</para>
     328 
     329<screen role="root"><userinput>cat &gt; /etc/profile.d/xterm-titlebars.sh &lt;&lt; "EOF"
     330<literal># The substring match ensures this works for "xterm" and "xterm-xfree86".
    319331if [ "${TERM:0:5}" = "xterm" ]; then
    320332  PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME} : ${PWD}\007"'
    321333  export PROMPT_COMMAND
    322 fi
    323 <command>EOF</command></userinput></screen>
    324 </sect3>
    325 
    326 <sect3 id="i18n.sh">
    327 <title><filename>/etc/profile.d/i18n.sh</filename></title>
    328 <indexterm zone="postlfs-config-profile i18n.sh">
    329 <primary
    330 sortas="e-etc-profile.d-i18n.sh">/etc/profile.d/i18n.sh</primary>
    331 </indexterm>
    332 
    333 <para>This script shows how to set some environment variables necessary for
    334 native language support. Setting these variables properly gives you:</para>
    335 
    336 <itemizedlist spacing="compact">
    337 <listitem><para>the output of programs translated into your native
    338 language</para></listitem>
    339 <listitem><para>correct classification of characters into letters, digits and
    340 other classes &ndash; this is necessary for <application>Bash</application> to
    341 accept keystrokes properly in non-English locales</para></listitem>
    342 <listitem><para>the alphabetical sorting order correct for your
    343 country</para></listitem>
    344 <listitem><para>proper default paper size</para></listitem>
    345 <listitem><para>correct formatting of monetary, time and date
    346 values</para></listitem>
    347 </itemizedlist>
    348 
    349 <para>Replace <replaceable>[ll]</replaceable> with the two-letter code for
    350 your language (e.g., <quote>en</quote>) and
    351 <replaceable>[CC]</replaceable> with the two-letter code for your country
    352 (e.g., <quote>GB</quote>). Also you may need to specify (and this is actually
    353 the preferred form) your character encoding (e.g., <quote>iso8859-1</quote>)
    354 after a dot (so that the result is <quote>en_GB.iso8859-1</quote>). Issue the
    355 following command for more information:</para>
    356 
    357 <screen><userinput><command>man 3 setlocale</command></userinput></screen>
    358 
    359 <para>The list of all locales supported by <application>Glibc</application>
    360 can be obtained by running the following command:</para>
    361 
    362 <screen><userinput><command>locale -a</command></userinput></screen>
    363 
    364 <para>After you are sure about your locale settings, create the
    365 <filename>/etc/profile.d/i18n.sh</filename> file:</para>
    366  
    367 <screen><userinput><command>cat &gt; /etc/profile.d/i18n.sh &lt;&lt; "EOF"</command>
    368 # Set up i18n variables
     334fi</literal>
     335EOF</userinput></screen>
     336
     337    </sect3>
     338
     339    <sect3 id="i18n.sh">
     340      <title><filename>/etc/profile.d/i18n.sh</filename></title>
     341
     342    <indexterm zone="postlfs-config-profile i18n.sh">
     343      <primary sortas="e-etc-profile.d-i18n.sh">/etc/profile.d/i18n.sh</primary>
     344    </indexterm>
     345
     346      <para>This script shows how to set some environment variables necessary for
     347      native language support. Setting these variables properly gives you:</para>
     348
     349      <itemizedlist>
     350        <listitem>
     351          <para>the output of programs translated into your native language</para>
     352        </listitem>
     353        <listitem>
     354          <para>correct classification of characters into letters, digits and
     355          other classes &ndash; this is necessary for <application>Bash</application>
     356          to accept keystrokes properly in non-English locales</para>
     357        </listitem>
     358        <listitem>
     359          <para>the alphabetical sorting order correct for your country</para>
     360        </listitem>
     361        <listitem>
     362          <para>proper default paper size</para>
     363        </listitem>
     364        <listitem>
     365          <para>correct formatting of monetary, time and date values</para>
     366        </listitem>
     367      </itemizedlist>
     368
     369      <para>Replace <replaceable>[ll]</replaceable> with the two-letter code for
     370      your language (e.g., <quote>en</quote>) and
     371      <replaceable>[CC]</replaceable> with the two-letter code for your country
     372      (e.g., <quote>GB</quote>). Also you may need to specify (and this is actually
     373      the preferred form) your character encoding (e.g., <quote>iso8859-1</quote>)
     374      after a dot (so that the result is <quote>en_GB.iso8859-1</quote>). Issue the
     375      following command for more information:</para>
     376
     377<screen><userinput>man 3 setlocale</userinput></screen>
     378
     379      <para>The list of all locales supported by <application>Glibc</application>
     380      can be obtained by running the following command:</para>
     381
     382<screen><userinput>locale -a</userinput></screen>
     383
     384      <para>After you are sure about your locale settings, create the
     385      <filename>/etc/profile.d/i18n.sh</filename> file:</para>
     386 
     387<screen role="root"><userinput>cat &gt; /etc/profile.d/i18n.sh &lt;&lt; "EOF"
     388<literal># Set up i18n variables
    369389export LC_ALL=<replaceable>[ll]</replaceable>_<replaceable>[CC]</replaceable>
    370390export LANG=<replaceable>[ll]</replaceable>_<replaceable>[CC]</replaceable>
    371 export G_FILENAME_ENCODING=@locale
    372 <command>EOF</command></userinput></screen>
    373 
    374 <para>The <envar>LC_ALL</envar> variable sets the same value for all locale
    375 categories. For better control, you may prefer to set values individually for
    376 all categories listed in the output of the <command>locale</command>
    377 command.</para>
    378 
    379 <para>The <envar>G_FILENAME_ENCODING</envar> variable tells applications
    380 such as <application>Glib</application> and
    381 <application><acronym>GTK</acronym>+</application> that filenames are in
    382 the default locale encoding and not in <acronym>UTF</acronym>-8 as
    383 assumed by default.</para>
    384 </sect3>
    385 
    386 <sect3>
    387 <title><filename>Other initialization values</filename></title>
    388 
    389 <para>Other initialization can easily be added to the
    390 <filename>profile</filename> by adding additional scripts to the
    391 <filename class='directory'>/etc/profile.d</filename> directory.</para>
    392 </sect3>
    393 
    394 </sect2>
    395 
    396 <sect2 id="etc-bashrc-profile">
    397 <title><filename>/etc/bashrc</filename></title>
    398 <indexterm zone="postlfs-config-profile etc-bashrc-profile">
    399 <primary sortas="e-etc-bashrc">/etc/bashrc</primary>
    400 </indexterm>
    401 
    402 <para>Here is a base <filename>/etc/bashrc</filename>.  Comments in the
    403 file should explain everything you need.</para>
    404 
    405 <screen><userinput><command>cat &gt; /etc/bashrc &lt;&lt; "EOF"</command>
    406 # Begin /etc/bashrc
     391export G_FILENAME_ENCODING=@locale</literal>
     392EOF</userinput></screen>
     393
     394      <para>The <envar>LC_ALL</envar> variable sets the same value for all locale
     395      categories. For better control, you may prefer to set values individually for
     396      all categories listed in the output of the <command>locale</command>
     397      command.</para>
     398
     399      <para>The <envar>G_FILENAME_ENCODING</envar> variable tells applications
     400      such as <application>Glib</application> and <application>GTK+</application>
     401      that filenames are in the default locale encoding and not in UTF-8 as
     402      assumed by default.</para>
     403
     404    </sect3>
     405
     406    <sect3>
     407      <title>Other Initialization Values</title>
     408
     409      <para>Other initialization can easily be added to the
     410      <filename>profile</filename> by adding additional scripts to the
     411      <filename class='directory'>/etc/profile.d</filename> directory.</para>
     412
     413    </sect3>
     414
     415  </sect2>
     416
     417  <sect2 id="etc-bashrc-profile">
     418    <title>/etc/bashrc</title>
     419
     420    <indexterm zone="postlfs-config-profile etc-bashrc-profile">
     421      <primary sortas="e-etc-bashrc">/etc/bashrc</primary>
     422    </indexterm>
     423
     424    <para>Here is a base <filename>/etc/bashrc</filename>.  Comments in the
     425    file should explain everything you need.</para>
     426
     427<screen role="root"><userinput>cat &gt; /etc/bashrc &lt;&lt; "EOF"
     428<literal># Begin /etc/bashrc
    407429# Written for Beyond Linux From Scratch
    408430# by James Robertson &lt;jameswrobertson@earthlink.net&gt;
     
    432454
    433455# Provides prompt for non-login shells, specifically shells started
    434 # in the <application>X</application> environment. [Review the LFS archive thread titled
     456# in the X environment. [Review the LFS archive thread titled
    435457# PS1 Environment Variable for a great case study behind this script
    436458# addendum.]
     
    439461export PS1='\u@\h:\w\$ '
    440462
    441 # End /etc/bashrc
    442 <command>EOF</command></userinput></screen>
    443 </sect2>
    444 
    445 <sect2 id="bash_profile-profile">
    446 <title><filename>~/.bash_profile</filename></title>
    447 <indexterm zone="postlfs-config-profile bash_profile-profile">
    448 <primary sortas="e-AA.bash_profile">~/.bash_profile</primary>
    449 </indexterm>
    450 
    451 <para>Here is a base <filename>~/.bash_profile</filename>.  If you want each
    452 new user to have this file automatically, just change the output of
    453 the command to <filename>/etc/skel/.bash_profile</filename> and check the
    454 permissions after the command is run. You can then copy
    455 <filename>/etc/skel/.bash_profile</filename> to the home directories of already
    456 existing users, including root, and set the owner and group appropriately.
    457 </para>
    458 
    459 <screen><userinput><command>cat &gt; ~/.bash_profile &lt;&lt; "EOF"</command>
    460 # Begin ~/.bash_profile
     463# End /etc/bashrc</literal>
     464EOF</userinput></screen>
     465
     466  </sect2>
     467
     468  <sect2 id="bash_profile-profile">
     469    <title>~/.bash_profile</title>
     470
     471    <indexterm zone="postlfs-config-profile bash_profile-profile">
     472      <primary sortas="e-AA.bash_profile">~/.bash_profile</primary>
     473    </indexterm>
     474
     475    <para>Here is a base <filename>~/.bash_profile</filename>.  If you want each
     476    new user to have this file automatically, just change the output of
     477    the command to <filename>/etc/skel/.bash_profile</filename> and check the
     478    permissions after the command is run. You can then copy
     479    <filename>/etc/skel/.bash_profile</filename> to the home directories of already
     480    existing users, including <systemitem class="username">root</systemitem>,
     481    and set the owner and group appropriately.</para>
     482
     483<screen><userinput>cat &gt; ~/.bash_profile &lt;&lt; "EOF"
     484<literal># Begin ~/.bash_profile
    461485# Written for Beyond Linux From Scratch
    462486# by James Robertson &lt;jameswrobertson@earthlink.net&gt;
     
    493517unset append
    494518
    495 # End ~/.bash_profile
    496 <command>EOF</command></userinput></screen>
    497 </sect2>
    498  
    499 <sect2 id="bashrc-profile">
    500 <title><filename>~/.bashrc</filename></title>
    501 <indexterm zone="postlfs-config-profile bashrc-profile">
    502 <primary sortas="e-AA.bashrc">~/.bashrc</primary>
    503 </indexterm>
    504 
    505 <para>Here is a base <filename>~/.bashrc</filename>.  The comments and
    506 instructions for using <filename class="directory">/etc/skel</filename> for
    507 <filename>.bash_profile</filename> above also apply here. Only the target file
    508 names are different.</para>
    509 
    510 <screen><userinput><command>cat &gt; ~/.bashrc &lt;&lt; "EOF"</command>
    511 # Begin ~/.bashrc
     519# End ~/.bash_profile</literal>
     520EOF</userinput></screen>
     521
     522  </sect2>
     523 
     524  <sect2 id="bashrc-profile">
     525    <title>~/.bashrc</title>
     526
     527    <indexterm zone="postlfs-config-profile bashrc-profile">
     528      <primary sortas="e-AA.bashrc">~/.bashrc</primary>
     529    </indexterm>
     530
     531    <para>Here is a base <filename>~/.bashrc</filename>.  The comments and
     532    instructions for using <filename class="directory">/etc/skel</filename> for
     533    <filename>.bash_profile</filename> above also apply here. Only the target file
     534    names are different.</para>
     535
     536<screen><userinput>cat &gt; ~/.bashrc &lt;&lt; "EOF"
     537<literal># Begin ~/.bashrc
    512538# Written for Beyond Linux From Scratch
    513539# by James Robertson &lt;jameswrobertson@earthlink.net&gt;
     
    524550fi
    525551
    526 # End ~/.bashrc
    527 <command>EOF</command></userinput></screen>
    528 </sect2>
    529  
    530  
    531 <sect2 id="bash_logout-profile">
    532 <title><filename>~/.bash_logout</filename></title>
    533 <indexterm zone="postlfs-config-profile bash_logout-profile">
    534 <primary sortas="e-AA.bash_logout">~/.bash_logout</primary>
    535 </indexterm>
    536 
    537 <para>This is an empty <filename>~/.bash_logout</filename> that can be used as
    538 a template.  You will notice that the base <filename>~/.bash_logout</filename>
    539 does not include a <userinput>clear</userinput> command.  This is because the
    540 clear is handled in the <filename>/etc/issue</filename> file.</para>
    541 
    542 <screen><userinput><command>cat &gt; ~/.bash_logout &lt;&lt; "EOF"</command>
    543 # Begin ~/.bash_logout
     552# End ~/.bashrc</literal>
     553EOF</userinput></screen>
     554
     555  </sect2>
     556 
     557 
     558  <sect2 id="bash_logout-profile">
     559    <title>~/.bash_logout</title>
     560
     561    <indexterm zone="postlfs-config-profile bash_logout-profile">
     562      <primary sortas="e-AA.bash_logout">~/.bash_logout</primary>
     563    </indexterm>
     564
     565    <para>This is an empty <filename>~/.bash_logout</filename> that can be used as
     566    a template.  You will notice that the base <filename>~/.bash_logout</filename>
     567    does not include a <userinput>clear</userinput> command.  This is because the
     568    clear is handled in the <filename>/etc/issue</filename> file.</para>
     569
     570<screen><userinput>cat &gt; ~/.bash_logout &lt;&lt; "EOF"
     571<literal># Begin ~/.bash_logout
    544572# Written for Beyond Linux From Scratch
    545573# by James Robertson &lt;jameswrobertson@earthlink.net&gt;
     
    547575# Personal items to perform on logout.
    548576
    549 # End ~/.bash_logout
    550 <command>EOF</command></userinput></screen>
    551 </sect2>
    552  
    553  
    554 <sect2 id="etc-dircolors-profile">
    555 <title><filename>/etc/dircolors</filename></title>
    556 <indexterm zone="postlfs-config-profile etc-dircolors-profile">
    557 <primary sortas="e-etc-dircolors">/etc/dircolors</primary>
    558 </indexterm>
    559 <indexterm zone="postlfs-config-profile etc-dircolors-profile">
    560 <primary sortas="e-AA.dircolors">~/.dircolors</primary>
    561 </indexterm>
    562 
    563 <para> If you want to use the <filename>dircolors</filename> capability, then
    564 run the following command. The <filename class="directory">/etc/skel</filename>
    565 setup steps seen above also can be used here to provide a
    566 <filename>~/.dircolors</filename> file when a new user is set up. As before,
    567 just change the output file name on the following command and assure the
    568 permissions, owner, and group are correct on the files created and/or copied.
    569 </para>
    570 
    571 <screen><userinput><command>dircolors -p > /etc/dircolors</command></userinput></screen>
    572 
    573 <para>If you wish to customize the colors used for different file types, you can
    574 edit the <filename>/etc/dircolors</filename> file.  The instructions for setting
    575 the colors are embedded in the file.</para>
    576 
    577 
    578 <para>Finally, Ian Macdonald has written an excellent collection of tips and
    579 tricks to enhance your shell environment.  You can read it online at
    580 <ulink
    581 url="http://www.caliban.org/bash/index.shtml">
    582 http://www.caliban.org/bash/index.shtml</ulink>.</para>
    583 </sect2>
     577# End ~/.bash_logout</literal>
     578EOF</userinput></screen>
     579
     580  </sect2>
     581 
     582 
     583  <sect2 id="etc-dircolors-profile">
     584    <title>/etc/dircolors</title>
     585
     586    <indexterm zone="postlfs-config-profile etc-dircolors-profile">
     587      <primary sortas="e-etc-dircolors">/etc/dircolors</primary>
     588    </indexterm>
     589
     590    <indexterm zone="postlfs-config-profile etc-dircolors-profile">
     591      <primary sortas="e-AA.dircolors">~/.dircolors</primary>
     592    </indexterm>
     593
     594    <para> If you want to use the <filename>dircolors</filename> capability, then
     595    run the following command. The <filename class="directory">/etc/skel</filename>
     596    setup steps seen above also can be used here to provide a
     597    <filename>~/.dircolors</filename> file when a new user is set up. As before,
     598    just change the output file name on the following command and assure the
     599    permissions, owner, and group are correct on the files created and/or
     600    copied.</para>
     601
     602<screen role="root"><userinput>dircolors -p > /etc/dircolors</userinput></screen>
     603
     604    <para>If you wish to customize the colors used for different file types, you can
     605    edit the <filename>/etc/dircolors</filename> file.  The instructions for setting
     606    the colors are embedded in the file.</para>
     607
     608
     609    <para>Finally, Ian Macdonald has written an excellent collection of tips and
     610    tricks to enhance your shell environment.  You can read it online at
     611    <ulink url="http://www.caliban.org/bash/index.shtml">
     612    http://www.caliban.org/bash/index.shtml</ulink>.</para>
     613
     614  </sect2>
     615
    584616</sect1>
Note: See TracChangeset for help on using the changeset viewer.