Ignore:
Timestamp:
03/25/2020 03:07:11 PM (4 years ago)
Author:
Pierre Labastie <pieere@…>
Branches:
10.0, 10.1, 11.0, 11.1, 11.2, 11.3, 12.0, 12.1, kea, ken/TL2024, ken/inkscape-core-mods, ken/tuningfonts, lazarus, lxqt, plabs/newcss, plabs/python-mods, python3.11, qt5new, rahul/power-profiles-daemon, renodr/vulkan-addition, trunk, upgradedb, xry111/intltool, xry111/llvm18, xry111/soup3, xry111/test-20220226, xry111/xf86-video-removal
Children:
986f53b9
Parents:
fa3edfef
Message:

Format postlfs config

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • postlfs/config/profile.xml

    rfa3edfef r81a73ed8  
    1616  <title>The Bash Shell Startup Files</title>
    1717
    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
    28   <filename>/etc/passwd</filename> file. This shell invocation normally reads
    29   <filename>/etc/profile</filename> and its private equivalent
    30   <filename>~/.bash_profile</filename> (or <filename>~/.profile</filename> if
    31   called as <command>/bin/sh</command>) upon startup.</para>
    32 
    33   <para>An interactive non-login shell is normally started at the command-line
    34   using a shell program (e.g.,
    35   <prompt>[prompt]$</prompt><command>/bin/bash</command>) or by the
    36   <command>/bin/su</command> command.  An interactive non-login shell is also
    37   started with a terminal program such as <command>xterm</command> or
    38   <command>konsole</command> from within a graphical environment. This type of
    39   shell invocation normally copies the parent environment and then reads the
    40   user's <filename>~/.bashrc</filename> file for additional startup
    41   configuration instructions.</para>
    42 
    43   <para>A non-interactive shell is usually present when a shell script is
    44   running.  It is non-interactive because it is processing a script and not
    45   waiting for user input between commands. For these shell invocations, only
    46   the environment inherited from the parent shell is used.</para>
    47 
    48   <para> The file <filename>~/.bash_logout</filename> is not used for an
    49   invocation of the shell.  It is read and executed when a user exits from an
    50   interactive login shell.</para>
    51 
    52   <para>Many distributions use <filename>/etc/bashrc</filename> for system wide
    53   initialization of non-login shells. This file is usually called from the
    54   user's <filename>~/.bashrc</filename> file and is not built directly into
    55   <command>bash</command> itself.  This convention is followed in this
    56   section.</para>
    57 
    58   <para>For more information see <command>info bash</command> --
    59   <emphasis role="strong">Nodes: Bash Startup Files and Interactive
    60   Shells</emphasis>.</para>
     18  <para>
     19    The shell program <filename>/bin/bash</filename> (hereafter referred to
     20    as just "the shell") uses a collection of startup files to help create
     21    an environment.  Each file has a specific use and may affect login and
     22    interactive environments differently.  The files in the <filename
     23    class="directory">/etc</filename> directory generally provide global
     24    settings. If an equivalent file exists in your home directory it may
     25    override the global settings.
     26  </para>
     27
     28  <para>
     29    An interactive login shell is started after a successful login, using
     30    <filename>/bin/login</filename>, by reading the
     31    <filename>/etc/passwd</filename> file. This shell invocation normally reads
     32    <filename>/etc/profile</filename> and its private equivalent
     33    <filename>~/.bash_profile</filename> (or <filename>~/.profile</filename>
     34    if called as <command>/bin/sh</command>) upon startup.
     35  </para>
     36
     37  <para>
     38    An interactive non-login shell is normally started at the command-line
     39    using a shell program (e.g.,
     40    <prompt>[prompt]$</prompt><command>/bin/bash</command>) or by the
     41    <command>/bin/su</command> command.  An interactive non-login shell is also
     42    started with a terminal program such as <command>xterm</command> or
     43    <command>konsole</command> from within a graphical environment. This type
     44    of shell invocation normally copies the parent environment and then reads
     45    the user's <filename>~/.bashrc</filename> file for additional startup
     46    configuration instructions.
     47  </para>
     48
     49  <para>
     50    A non-interactive shell is usually present when a shell script is
     51    running.  It is non-interactive because it is processing a script and not
     52    waiting for user input between commands. For these shell invocations, only
     53    the environment inherited from the parent shell is used.
     54  </para>
     55
     56  <para>
     57    The file <filename>~/.bash_logout</filename> is not used for an
     58    invocation of the shell.  It is read and executed when a user exits from an
     59    interactive login shell.
     60  </para>
     61
     62  <para>
     63    Many distributions use <filename>/etc/bashrc</filename> for system wide
     64    initialization of non-login shells. This file is usually called from the
     65    user's <filename>~/.bashrc</filename> file and is not built directly into
     66    <command>bash</command> itself.  This convention is followed in this
     67    section.
     68  </para>
     69
     70  <para>
     71    For more information see <command>info bash</command> --
     72    <emphasis role="strong">Nodes: Bash Startup Files and Interactive
     73    Shells</emphasis>.
     74  </para>
    6175
    6276  <note>
    63     <para>Most of the instructions below are used to create files located in
    64     the <filename class='directory'>/etc</filename> directory structure which
    65     requires you to execute the commands as the
    66     <systemitem class='username'>root</systemitem> user. If you elect to create
    67     the files in user's home directories instead, you should run the commands
    68     as an unprivileged user.</para>
     77    <para>
     78      Most of the instructions below are used to create files located in the
     79      <filename class='directory'>/etc</filename> directory structure which
     80      requires you to execute the commands as the <systemitem
     81      class='username'>root</systemitem> user. If you elect to create the
     82      files in user's home directories instead, you should run the commands
     83      as an unprivileged user.
     84    </para>
    6985  </note>
    7086
    71     <para condition="html" role="usernotes">User Notes:
    72     <ulink url="&blfs-wiki;/bash-shell-startup-files"/></para>
     87  <para condition="html" role="usernotes">User Notes:
     88  <ulink url="&blfs-wiki;/bash-shell-startup-files"/></para>
    7389
    7490  <sect2 id="etc-profile-profile">
     
    7995    </indexterm>
    8096
    81     <para>Here is a base <filename>/etc/profile</filename>. This file starts by
    82     setting up some helper functions and some basic parameters.  It specifies some
    83     <command>bash</command> history parameters and, for security purposes,
    84     disables keeping a permanent history file for the <systemitem
    85     class="username">root</systemitem> user.  It also sets a
    86     default user prompt.  It then calls small, single purpose scripts in the
    87     <filename class='directory'>/etc/profile.d</filename> directory to provide most
    88     of the initialization.</para>
    89 
    90     <para>For more information on the escape sequences you can use for your prompt
    91     (i.e., the <envar>PS1</envar> environment variable) see <command>info
    92     bash</command> -- <emphasis role="strong">Node: Printing a
    93     Prompt</emphasis>.</para>
     97    <para>
     98      Here is a base <filename>/etc/profile</filename>. This file starts by
     99      setting up some helper functions and some basic parameters. It specifies
     100      some <command>bash</command> history parameters and, for security
     101      purposes, disables keeping a permanent history file for the <systemitem
     102      class="username">root</systemitem> user.  It also sets a default user
     103      prompt.  It then calls small, single purpose scripts in the <filename
     104      class='directory'>/etc/profile.d</filename> directory to provide most
     105      of the initialization.
     106    </para>
     107
     108    <para>
     109      For more information on the escape sequences you can use for your prompt
     110      (i.e., the <envar>PS1</envar> environment variable) see <command>info
     111      bash</command> -- <emphasis role="strong">Node: Printing a
     112      Prompt</emphasis>.
     113    </para>
    94114
    95115<screen role="root"><?dbfo keep-together="auto"?><userinput>cat &gt; /etc/profile &lt;&lt; "EOF"
     
    180200      </indexterm>
    181201
    182       <para>Now create the <filename class='directory'>/etc/profile.d</filename>
    183       directory, where the individual initialization scripts are placed:</para>
     202      <para>
     203        Now create the <filename class='directory'>/etc/profile.d</filename>
     204        directory, where the individual initialization scripts are placed:
     205      </para>
    184206
    185207<screen role="root"><userinput>install --directory --mode=0755 --owner=root --group=root /etc/profile.d</userinput></screen>
     
    194216      </indexterm>
    195217
    196       <note><para>Using the bash completion script below is controversial.
    197       Not all users like it.  It adds many (usually over 1000) lines to the
    198       bash environment and makes it difficult to use the 'set' command to
    199       examine simple environment variables.  Omitting this script does not
    200       interfere with the ability of bash to use the tab key for file name
    201       completion.</para></note>
    202 
    203       <para>This script imports bash completion scripts, installed by many
    204       other BLFS packages, to allow TAB command line completion.</para>
     218      <note>
     219        <para>
     220          Using the bash completion script below is controversial. Not all
     221          users like it.  It adds many (usually over 1000) lines to the bash
     222          environment and makes it difficult to use the 'set' command to
     223          examine simple environment variables.  Omitting this script does
     224          not interfere with the ability of bash to use the tab key for file
     225          name completion.
     226        </para>
     227      </note>
     228
     229      <para>
     230        This script imports bash completion scripts, installed by many
     231        other BLFS packages, to allow TAB command line completion.
     232      </para>
    205233
    206234<screen role="root"><userinput>cat &gt; /etc/profile.d/bash_completion.sh &lt;&lt; "EOF"
     
    240268# End /etc/profile.d/bash_completion.sh</literal>
    241269EOF</userinput></screen>
    242       <para>Make sure that the directory exists:</para>
     270      <para>
     271        Make sure that the directory exists:
     272      </para>
    243273
    244274<screen role="root"><userinput>install --directory --mode=0755 --owner=root --group=root /etc/bash_completion.d</userinput></screen>
    245275
    246       <para>For a more complete installation, see
    247       <ulink url="&blfs-wiki;/bash-shell-startup-files#bash-completions"/>.</para>
     276      <para>
     277        For a more complete installation, see
     278        <ulink url="&blfs-wiki;/bash-shell-startup-files#bash-completions"/>.
     279      </para>
    248280
    249281    </sect3>
     
    256288      </indexterm>
    257289
    258       <para>This script uses the <filename>~/.dircolors</filename> and
    259       <filename>/etc/dircolors</filename> files to control the colors of file names in a
    260       directory listing. They control colorized output of things like <command>ls
    261       --color</command>.  The explanation of how to initialize these files is at the
    262       end of this section.</para>
     290      <para>
     291        This script uses the <filename>~/.dircolors</filename> and
     292        <filename>/etc/dircolors</filename> files to control the colors of
     293        file names in a directory listing. They control colorized output of
     294        things like <command>ls --color</command>.  The explanation of how to
     295        initialize these files is at the end of this section.
     296      </para>
    263297
    264298<screen role="root"><userinput>cat &gt; /etc/profile.d/dircolors.sh &lt;&lt; "EOF"
     
    285319      </indexterm>
    286320
    287       <para>This script adds some useful paths to the <envar>PATH</envar> and
    288       can be used to customize other PATH related environment variables
    289       (e.g. LD_LIBRARY_PATH, etc) that may be needed for all users.</para>
     321      <para>
     322        This script adds some useful paths to the <envar>PATH</envar> and
     323        can be used to customize other PATH related environment variables
     324        (e.g. LD_LIBRARY_PATH, etc) that may be needed for all users.
     325      </para>
    290326
    291327<screen role="root"><userinput>cat &gt; /etc/profile.d/extrapaths.sh &lt;&lt; "EOF"
     
    314350      </indexterm>
    315351
    316       <para>This script sets up the default <filename>inputrc</filename>
    317       configuration file. If the user does not have individual settings, it uses the
    318       global file.</para>
     352      <para>
     353        This script sets up the default <filename>inputrc</filename>
     354        configuration file. If the user does not have individual settings, it
     355        uses the global file.
     356      </para>
    319357
    320358<screen role="root"><userinput>cat &gt; /etc/profile.d/readline.sh &lt;&lt; "EOF"
     
    335373      </indexterm>
    336374
    337       <para>Setting the <command>umask</command> value is important for security.
    338       Here the default group write permissions are turned off for system users and when
    339       the user name and group name are not the same.</para>
     375      <para>
     376        Setting the <command>umask</command> value is important for security.
     377        Here the default group write permissions are turned off for system
     378        users and when the user name and group name are not the same.
     379      </para>
    340380
    341381<screen role="root"><userinput>cat &gt; /etc/profile.d/umask.sh &lt;&lt; "EOF"
     
    358398      </indexterm>
    359399
    360       <para>If <application>X</application> is installed, the <envar>PATH</envar>
    361       and <envar>PKG_CONFIG_PATH</envar> variables are also updated.</para>
     400      <para>
     401        If <application>X</application> is installed, the <envar>PATH</envar>
     402        and <envar>PKG_CONFIG_PATH</envar> variables are also updated.
     403      </para>
    362404
    363405<screen role="root"><userinput>cat &gt; /etc/profile.d/X.sh &lt;&lt; "EOF"
     
    382424    </indexterm>
    383425
    384       <para>This script sets an environment variable necessary for
    385       native language support. A full discussion on determining this
    386       variable can be found on the <ulink
    387       url="&lfs-root;/chapter07/profile.html">LFS Bash Shell
    388       Startup Files</ulink> page.</para>
     426      <para>
     427        This script sets an environment variable necessary for
     428        native language support. A full discussion on determining this
     429        variable can be found on the <ulink
     430        url="&lfs-root;/chapter07/profile.html">LFS Bash Shell
     431        Startup Files</ulink> page.
     432      </para>
    389433
    390434<screen role="root" revision="sysv"><userinput>cat &gt; /etc/profile.d/i18n.sh &lt;&lt; "EOF"
     
    404448      <title>Other Initialization Values</title>
    405449
    406       <para>Other initialization can easily be added to the
    407       <filename>profile</filename> by adding additional scripts to the
    408       <filename class='directory'>/etc/profile.d</filename> directory.</para>
     450      <para>
     451        Other initialization can easily be added to the
     452        <filename>profile</filename> by adding additional scripts to the
     453        <filename class='directory'>/etc/profile.d</filename> directory.
     454      </para>
    409455
    410456    </sect3>
     
    419465    </indexterm>
    420466
    421     <para>Here is a base <filename>/etc/bashrc</filename>.  Comments in the
    422     file should explain everything you need.</para>
     467    <para>
     468      Here is a base <filename>/etc/bashrc</filename>.  Comments in the
     469      file should explain everything you need.
     470    </para>
    423471
    424472<screen role="root"><userinput>cat &gt; /etc/bashrc &lt;&lt; "EOF"
     
    469517    </indexterm>
    470518
    471     <para>Here is a base <filename>~/.bash_profile</filename>.  If you want each
    472     new user to have this file automatically, just change the output of
    473     the command to <filename>/etc/skel/.bash_profile</filename> and check the
    474     permissions after the command is run. You can then copy
    475     <filename>/etc/skel/.bash_profile</filename> to the home directories of already
    476     existing users, including <systemitem class="username">root</systemitem>,
    477     and set the owner and group appropriately.</para>
     519    <para>
     520      Here is a base <filename>~/.bash_profile</filename>.  If you want each
     521        new user to have this file automatically, just change the output of
     522      the command to <filename>/etc/skel/.bash_profile</filename> and check the
     523      permissions after the command is run. You can then copy <filename>
     524      /etc/skel/.bash_profile</filename> to the home directories of already
     525      existing users, including <systemitem class="username">root</systemitem>,
     526      and set the owner and group appropriately.
     527    </para>
    478528
    479529<screen><userinput>cat &gt; ~/.bash_profile &lt;&lt; "EOF"
     
    514564    </indexterm>
    515565
    516     <para>Here is a base <filename>~/.profile</filename>. The comments and
    517     instructions for using <filename class="directory">/etc/skel</filename> for
    518     <filename>.bash_profile</filename> above also apply here. Only the target
    519     file names are different.</para>
     566    <para>
     567      Here is a base <filename>~/.profile</filename>. The comments and
     568      instructions for using <filename class="directory">/etc/skel</filename>
     569      for <filename>.bash_profile</filename> above also apply here. Only the
     570      target file names are different.
     571    </para>
    520572
    521573<screen><userinput>cat &gt; ~/.profile &lt;&lt; "EOF"
     
    542594    </indexterm>
    543595
    544     <para>Here is a base <filename>~/.bashrc</filename>.</para>
     596    <para>
     597      Here is a base <filename>~/.bashrc</filename>.
     598    </para>
    545599
    546600<screen><userinput>cat &gt; ~/.bashrc &lt;&lt; "EOF"
     
    576630    </indexterm>
    577631
    578     <para>This is an empty <filename>~/.bash_logout</filename> that can be used as
    579     a template.  You will notice that the base <filename>~/.bash_logout</filename>
    580     does not include a <userinput>clear</userinput> command.  This is because the
    581     clear is handled in the <filename>/etc/issue</filename> file.</para>
     632    <para>
     633      This is an empty <filename>~/.bash_logout</filename> that can be used as
     634      a template.  You will notice that the base <filename>~/.bash_logout
     635      </filename> does not include a <userinput>clear</userinput> command.
     636      This is because the clear is handled in the
     637      <filename>/etc/issue</filename> file.
     638    </para>
    582639
    583640<screen><userinput>cat &gt; ~/.bash_logout &lt;&lt; "EOF"
     
    605662    </indexterm>
    606663
    607     <para> If you want to use the <filename>dircolors</filename> capability,
    608     then run the following command. The
    609     <filename class="directory">/etc/skel</filename> setup steps shown above
    610     also can be used here to provide a <filename>~/.dircolors</filename> file
    611     when a new user is set up. As before, just change the output file name on
    612     the following command and assure the permissions, owner, and group are
    613     correct on the files created and/or copied.</para>
     664    <para>
     665       If you want to use the <filename>dircolors</filename> capability, then
     666       run the following command. The <filename class="directory">/etc/skel
     667       </filename> setup steps shown above also can be used here to provide
     668       a <filename>~/.dircolors</filename> file when a new user is set up.
     669       As before, just change the output file name on the following command
     670       and assure the permissions, owner, and group are correct on the files
     671       created and/or copied.
     672    </para>
    614673
    615674<screen role="root"><userinput>dircolors -p > /etc/dircolors</userinput></screen>
    616675
    617     <para>If you wish to customize the colors used for different file types,
    618     you can edit the <filename>/etc/dircolors</filename> file. The instructions
    619     for setting the colors are embedded in the file.</para>
    620 
    621 
    622     <para>Finally, Ian Macdonald has written an excellent collection of tips and
    623     tricks to enhance your shell environment.  You can read it online at
    624     <ulink url="http://www.caliban.org/bash/index.shtml"/>.</para>
     676    <para>
     677      If you wish to customize the colors used for different file types, you
     678      can edit the <filename>/etc/dircolors</filename> file. The instructions
     679      for setting the colors are embedded in the file.
     680    </para>
     681
     682
     683    <para>
     684      Finally, Ian Macdonald has written an excellent collection of tips and
     685      tricks to enhance your shell environment.  You can read it online at
     686      <ulink url="http://www.caliban.org/bash/index.shtml"/>.
     687    </para>
    625688
    626689  </sect2>
Note: See TracChangeset for help on using the changeset viewer.