Changeset 1a396398


Ignore:
Timestamp:
05/28/2004 05:11:35 AM (20 years ago)
Author:
Bruce Dubbs <bdubbs@…>
Branches:
10.0, 10.1, 11.0, 11.1, 11.2, 11.3, 12.0, 12.1, 12.2, 6.0, 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, gimp3, 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, v5_1, v5_1-pre1, xry111/for-12.3, xry111/intltool, xry111/llvm18, xry111/soup3, xry111/spidermonkey128, xry111/test-20220226, xry111/xf86-video-removal
Children:
4faa9b91
Parents:
78349d6
Message:

Update to profile per Dagmar d'Surreal's suggestions

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

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • introduction/welcome/changelog.xml

    r78349d6 r1a396398  
    1111
    1212<itemizedlist>
     13
     14<listitem><para>May 27th, 2004 [bdubbs]: updated the /etc/profile
     15instructions per the suggestions of Dagmar d'Surreal.</para></listitem>
    1316
    1417<listitem><para>May 27th, 2004 [larry]: www.cvshome.org is partily
  • postlfs/config/profile.xml

    r78349d6 r1a396398  
    55<para>The shell program <filename>/bin/bash</filename> (hereafter
    66referred to as just "the shell") uses a collection of startup files to
    7 help create an environment to run in.  Each file has a specific use and
     7help create an environment.  Each file has a specific use and
    88may affect login and interactive environments differently.  The files in
    99the <filename class="directory">/etc</filename> directory generally provide global
     
    1313
    1414<para>An interactive login shell is started after a successful login, using
    15 <filename>/bin/login</filename>, by reading the
    16 <filename>/etc/passwd</filename> file.  An
    17 interactive non-login shell is started at the command-line (e.g.
    18 <prompt>[prompt]$</prompt><command>/bin/bash</command>).  A non-interactive
    19 shell is usually present when a shell script is running.  It is non-interactive
    20 because it is processing a script and not waiting for user input between
    21 commands.</para>
     15<filename>/bin/login</filename>, by reading the <filename>/etc/passwd</filename>
     16file.  This shell invocation normally reads <filename>/etc/profile</filename>
     17and its private equivalent <filename>~/.bash_profile</filename> upon startup.</para>
     18
     19<para>An interactive non-login shell is normally started at the command-line
     20(e.g.  <prompt>[prompt]$</prompt><command>/bin/bash</command>) or by the
     21<command>/bin/su</command> command.  An interactive non-login shell is also
     22started with a terminal program such as <command>xterm</command> or
     23<command>konsole</command> from within a graphical environment. This type of
     24shell invocation normally copies the parent environment and then reads the
     25user's <filename>~/.bashrc</filename> file for additional startup configuration
     26instructions.</para>
     27
     28<para>A non-interactive shell is usually present when a shell script is
     29running.  It is non-interactive because it is processing a script and not
     30waiting for user input between commands. For these shell invocatinos, only
     31the environment inherited form the parent shell is used.</para>
     32
     33<para> The file <filename>~/.bash_logout</filename> is not used for an
     34invocation of the shell.  It is read and executed when a user exits from an
     35interactive login shell.</para>
     36
     37<para>To the standard files, we also add <filename>/etc/bashrc</filename>
     38which is called from the user's <filename>~/.bashrc</filename> for
     39system wide initialization of non-login shells.</para>
    2240
    2341<para>For more information see <command>info bash</command> --
     
    2543Shells.</emphasis></para>
    2644
    27 <para>The following files are used to make sure that the correct
    28 environment is established for each of the ways the shell can be invoked:
    29 <filename>/etc/profile</filename> and its private equivalent
    30 <filename>~/.bash_profile</filename>, and
    31 <filename>/etc/bashrc</filename> (unofficial) and its private equivalent
    32 <filename>~/.bashrc</filename>.
    33 </para>
    34 
    35 <para>
    36 The file <filename>~/.bash_logout</filename> is not used for an
    37 invocation of the shell.  It is read by the shell when a user logs out
    38 of the system.</para>
    39 
    40 <para>The files <filename>/etc/profile</filename> and
    41 <filename>~/.bash_profile</filename> are read when the shell is invoked
    42 as an interactive login shell.  The file <filename>~/.bashrc</filename>
    43 is read when the shell is invoked as an interactive non-login
    44 shell and it reads <filename>/etc/bashrc</filename> if it exists</para>
    45 
    46 <para>Also useful are the <filename>/etc/dircolors</filename> and
    47 <filename>~/.dircolors</filename> files called from
    48 <filename>/etc/profile</filename>. They control colorized output of
    49 things like <command>ls --color</command>.
    50 </para>
    51 
    52 <para>Here is a base <filename>/etc/profile</filename>.  Comments in the
    53 file should explain everything you need.  For more information on the
    54 escape sequences you can use for your prompt (e.g.  the
    55 <envar>PS1</envar> environment variable) see <command>info
     45<sect2>
     46<title><filename>/etc/profile</filename></title>
     47
     48<para>Here is a base <filename>/etc/profile</filename>. This file starts by
     49setting up some helper functions and some basic parameters.  It specifies some
     50<filename>bash</filename> history parameters and, for security purposes,
     51disables keeping a permanent history file for the root user.  It also sets a
     52default user prompt.  It then calls small, single purpose scripts in the
     53<filename class='directory'>/etc/profile.d</filename> directory to provide most
     54initialization.  </para>
     55
     56<para>For more information on the escape sequences you can use for your prompt
     57(e.g.  the <envar>PS1</envar> environment variable) see <command>info
    5658bash</command> -- <emphasis role="strong">Node: Printing a
    5759Prompt.</emphasis></para>
     
    6163# Written for Beyond Linux From Scratch
    6264# by James Robertson &lt;jameswrobertson@earthlink.net&gt;
    63 
     65# modifications by Dagmar d'Surreal &lt;rivyqntzne@pbzpnfg.arg&gt;
     66 
    6467# System wide environment variables and startup programs.
    65 
     68 
    6669# System wide aliases and functions should go in /etc/bashrc.  Personal
    6770# environment variables and startup programs should go into
    6871# ~/.bash_profile.  Personal aliases and functions should go into
    6972# ~/.bashrc.
    70 
    71 # Function to help us manage paths
    72 pathman () {
    73         if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then
    74                 if [ "$2" = "last" ] ; then
    75                         PATH=$PATH:$1
    76                 else
    77                         PATH=$1:$PATH
    78                 fi
    79         fi
     73 
     74# Functions to help us manage paths.  Second argument is the name of the
     75# path variable to be modified (default: PATH)
     76pathremove () {
     77        local IFS=':'
     78        local NEWPATH
     79        local DIR
     80        local PATHVARIABLE=${2:-PATH}
     81        for DIR in ${!PATHVARIABLE} ; do
     82                if [ "$DIR" != "$1" ] ; then
     83                  NEWPATH=${NEWPATH:+$NEWPATH:}$DIR
     84                fi
     85        done
     86        export $PATHVARIABLE="$NEWPATH"
    8087}
    81 
    82 # Add to the standard path.
    83 if [ $(id -u) = 0 ] ; then
    84         if [ -d "/usr/local/sbin" ] ; then
    85                 pathman /usr/local/sbin last
    86         fi
    87 fi
    88 
    89 if [ $(id -u) != 0 ] ; then
    90         if [ -d "/usr/local/bin" ] ; then
    91                 pathman /usr/local/bin last
    92         fi
    93 fi
    94 
    95 if [ -d "/usr/X11R6/bin" ] ; then
    96         pathman /usr/X11R6/bin last
    97 fi
    98 
     88 
     89pathprepend () {
     90        pathremove $1 $2
     91        local PATHVARIABLE=${2:-PATH}
     92        export $PATHVARIABLE="$1${!PATHVARIABLE:+:${!PATHVARIABLE}}"
     93}
     94 
     95pathappend () {
     96        pathremove $1 $2
     97        local PATHVARIABLE=${2:-PATH}
     98        export $PATHVARIABLE="${!PATHVARIABLE:+${!PATHVARIABLE}:}$1"
     99}
     100 
     101if [ $EUID -eq 0 ] ; then
     102        unset HISTFILE
     103fi
     104 
    99105# Setup some environment variables.
    100 HISTSIZE=1000
    101 HISTIGNORE="&amp;:[bf]g:exit"
    102 PS1="[\u@\h \w]\\$ "
    103 
     106export HISTSIZE=1000
     107export HISTIGNORE="&amp;:[bf]g:exit"
     108#export PS1="[\u@\h \w]\\$ "
     109export PS1='\u@\h:\w\$ '
     110 
     111for script in /etc/profile.d/*.sh ; do
     112        if [ -x $script ] ; then
     113                . $script
     114        fi
     115done
     116 
     117# Now to clean up after ourselves
     118unset pathremove pathprepend pathappend
     119
     120# End /etc/profile
     121<command>EOF</command></userinput></screen>
     122
     123<para>Now create the <filename class='directory'>/etc/profile.d</filename> directory.</para>
     124
     125<screen><userinput><command>install --directory --mode=0755 --owner=root --group=root /etc/profile.d</command></userinput></screen>
     126
     127<sect3>
     128<title><filename>/etc/profile.d/dircolors.sh</filename></title>
     129
     130<para>This script uses the <filename>~/.dircolors</filename> and
     131<filename>/etc/dircolors</filename> files to control the colors of file names in a
     132directory listing. They control colorized output of things like <command>ls
     133--color</command>.  The explaination of how to initialize these files is at the
     134end of this section.  </para>
     135
     136
     137<screen><userinput><command>cat &gt; /etc/profile.d/dircolors.sh &lt;&lt; "EOF"</command>
     138# Setup for /bin/ls to support color, the alias is in /etc/bashrc.
     139if [ -f "/etc/dircolors" ] ; then
     140        eval $(dircolors -b /etc/dircolors)
     141 
     142        if [ -f "$HOME/.dircolors" ] ; then
     143                eval $(dircolors -b $HOME/.dircolors)
     144        fi
     145fi
     146alias ls='ls --color=auto'
     147<command>EOF</command></userinput></screen>
     148</sect3>
     149
     150
     151<sect3>
     152<title><filename>/etc/profile.d/extrapaths.sh</filename></title>
     153
     154<para>This script adds several useful paths to the <envar>PATH</envar> and
     155<envar>PKG_CONFIG_PATH</envar> environment variables.  If you want, you can uncomment
     156the last section to put a dot at the end of your path. This will allow executables in the
     157current working directoty to be executed without specifiying a ./, however
     158you are warned that this is generally considered a security hazard.</para>
     159 
     160<screen><userinput><command>cat &gt; /etc/profile.d/extrapaths.sh &lt;&lt; "EOF"</command>
     161if [ -d /usr/local/lib/pkgconfig ] ; then
     162        pathappend /usr/local/lib/pkgconfig PKG_CONFIG_PATH
     163fi
     164if [ -d /usr/local/bin ]; then
     165        pathprepend /usr/local/bin
     166fi
     167if [ -d /usr/local/sbin -a $EUID -eq 0 ]; then
     168        pathprepend /usr/local/sbin
     169fi
     170for directory in $(find /opt/*/lib/pkgconfig -type d); do
     171        pathappend $directory PKG_CONFIG_PATH
     172done
     173for directory in $(find /opt/*/bin -type d); do
     174        pathappend $directory
     175done
     176if [ -d ~/bin ]; then
     177        pathprepend ~/bin
     178fi
     179#if [ $EUID -gt 99 ]; then
     180#        pathappend .
     181#fi
     182<command>EOF</command></userinput></screen>
     183</sect3>
     184
     185<sect3>
     186<title><filename>/etc/profile.d/readline.sh</filename></title>
     187
     188<para>This script sets up the default <filename>inputrc</filename> configuration file.
     189If the user does not have individual settings, it uses the global file.</para>
     190
     191<screen><userinput><command>cat &gt; /etc/profile.d/readline.sh &lt;&lt; "EOF"</command>
    104192# Setup the INPUTRC environment variable.
    105193if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ] ; then
    106         INPUTRC=/etc/inputrc
    107 fi
    108 
    109 # Setup for /bin/ls to support color, the alias is in /etc/bashrc.
    110 if [ -f "/etc/dircolors" ] ; then
    111         eval $(dircolors -b /etc/dircolors)
    112 
    113         if [ -f "$HOME/.dircolors" ] ; then
    114                 eval $(dircolors -b $HOME/.dircolors)
    115         fi
    116 fi
    117 
    118 export PATH HISTSIZE HISTIGNORE PS1 LS_COLORS INPUTRC
    119 
    120 # End /etc/profile
    121 <command>EOF</command></userinput></screen>
    122 
     194        INPUTRC=/etc/inputrc
     195fi
     196export INPUTRC
     197<command>EOF</command></userinput></screen>
     198</sect3>
     199
     200<sect3>
     201<title><filename>/etc/profile.d/tinker-term.sh</filename></title>
     202
     203<para>Some applications need a specific <envar>TERM</envar> setting to support color.</para>
     204
     205<screen><userinput><command>cat &gt; /etc/profile.d/tinker-term.sh &lt;&lt; "EOF"</command>
     206# This will tinker with the value of TERM in order to convince certain apps
     207# that we can, indeed, display color in their window.
     208 
     209if [ -n "$COLORTERM" ]; then
     210  export TERM=xterm-color
     211fi
     212 
     213if [ "$TERM" = "xterm" ]; then
     214  export TERM=xterm-color
     215fi
     216<command>EOF</command></userinput></screen>
     217</sect3>
     218
     219<sect3>
     220<title><filename>/etc/profile.d/umask.sh</filename></title>
     221 
     222<para>Setting the <command>umask</command> value is important for security. Here
     223we turn off the default group write permissions for system users and when the
     224user name and group name are not the same.</para>
     225
     226<screen><userinput><command>cat &gt; /etc/profile.d/umask.sh &lt;&lt; "EOF"</command>
     227# By default we want the umask to get set.
     228if [ "$(id -gn)" = "$(id -un)" -a $EUID -gt 99 ] ; then
     229  umask 002
     230else
     231  umask 022
     232fi
     233<command>EOF</command></userinput></screen>
     234</sect3>
     235
     236<sect3>
     237<title><filename>/etc/profile.d/X.sh</filename></title>
     238
     239<para>If <application>X</application> is installed, we also update the <envar>PATH</envar>
     240and <envar>PKG_CONFIG_PATH</envar> variables.</para>
     241
     242<screen><userinput><command>cat &gt; /etc/profile.d/X.sh &lt;&lt; "EOF"</command>
     243if [ -x /usr/X11R6/bin/X ]; then
     244        pathappend /usr/X11R6/bin
     245fi
     246if [ -d /usr/X11R6/lib/pkgconfig ] ; then
     247        pathappend /usr/X11R6/lib/pkgconfig PKG_CONFIG_PATH
     248fi
     249<command>EOF</command></userinput></screen>
     250</sect3>
     251
     252<sect3>
     253<title><filename>/etc/profile.d/xterm-titlebars.sh</filename></title>
     254 
     255<para>This script shows an example of a different way of setting the prompt.  The normal
     256variable, <envar>PS1</envar>, is supplemented by <envar>PROMPT_COMMAND</envar>.
     257If set, the value of <envar>PROMPT_COMMAND</envar> is executed as a command prior to
     258issuing each primary prompt. </para>
     259 
     260<screen><userinput><command>cat &gt; /etc/profile.d/xterm-titlebars.sh &lt;&lt; "EOF"</command>
     261# The substring match ensures this will work for "xterm" and "xterm-xfree86".
     262if [ "${TERM:0:5}" = "xterm" ]; then
     263  PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME} : ${PWD}\007"'
     264  export PROMPT_COMMAND
     265fi
     266<command>EOF</command></userinput></screen>
     267
     268<para>Other initialization can easily be added to the <filename>profile</filename>
     269by adding additional scripts to the
     270<filename class='directory'>/etc/profile.d</filename> directory.</para>
     271</sect3>
     272</sect2>
     273
     274<sect2>
     275<title><filename>/etc/bashrc</filename></title>
    123276<para>Here is a base <filename>/etc/bashrc</filename>.  Comments in the
    124277file should explain everything you need.</para>
     
    136289# go into ~/.bashrc
    137290
    138 # By default we want the umask to get set.
    139 # Even for non-interactive and non-login shells.
    140 if [ "$(id -gn)" = "$(id -un)" -a $(id -u) -gt 99 ] ; then
    141         umask 002
    142 else
    143         umask 022
    144 fi
    145 
    146291# Provides a colored /bin/ls command.  Used in conjunction with code in
    147292# /etc/profile.
     293
    148294alias ls='ls --color=auto'
    149295
    150 # Provides prompt for non-interactive shells, specifically shells started
    151 # in the xfree environment. [Review archive thread titled PS1
    152 # Environment Variable for a great case study behind this script
    153 # addendum.]
     296# Provides prompt for non-login shells, specifically shells started
     297# in the <application>X</application> environment. [Review the LFS archive thread titled
     298# PS1 Environment Variable for a great case study behind this script addendum.]
     299
    154300export PS1="[\u@\h \w]\\$ "
    155301
    156302# End /etc/bashrc
    157303<command>EOF</command></userinput></screen>
    158 
    159 <para>Here is a base <filename>~/.bash_profile</filename>.  Comments in
    160 the file should explain everything you need.  If you want each new user
    161 to have this file automatically provided, just change the output of the
    162 next command to <filename>/etc/skel/.bash_profile</filename> and check the
     304</sect2>
     305
     306
     307<sect2>
     308<title><filename>~/.bash_profile</filename></title>
     309
     310<para>Here is a base <filename>~/.bash_profile</filename>.  If you want each
     311new user to have this file automatically, just change the output of
     312the command to <filename>/etc/skel/.bash_profile</filename> and check the
    163313permissions after the command is run. You can then copy
    164 <filename>/etc/skel/.bash_profile</filename> to the home directories of
    165 already existing users, including root, and set the owner and group
    166 appropriately.
     314<filename>/etc/skel/.bash_profile</filename> to the home directories of already
     315existing users, including root, and set the owner and group appropriately.
    167316</para>
    168317
     
    171320# Written for Beyond Linux From Scratch
    172321# by James Robertson &lt;jameswrobertson@earthlink.net&gt;
     322# updated by Bruce Dubbs &lt;bdubbs@linuxfromscratch.org&gt;
    173323
    174324# Personal environment variables and startup programs.
     
    178328# System wide aliases and functions are in /etc/bashrc.
    179329
     330append () {
     331  # First remove the directory
     332  local IFS=':'
     333  local NEWPATH
     334  for DIR in $PATH; do
     335     if [ "$DIR" != "$1" ]; then
     336       NEWPATH = ${NEWPATH:+$NEWPATH:}$DIR
     337     fi     
     338  done
     339 
     340  # Then append the directory
     341  export PATH=$NEWPATH:$1
     342}
     343
    180344if [ -f "$HOME/.bashrc" ] ; then
    181345        source $HOME/.bashrc
     
    183347
    184348if [ -d "$HOME/bin" ] ; then
    185         pathman $HOME/bin last
    186 fi
    187 
    188 export PATH
     349  append $HOME/bin     
     350fi
     351
     352unset append
    189353
    190354# End ~/.bash_profile
    191355<command>EOF</command></userinput></screen>
    192 
    193 <para>Here is a base <filename>~/.bashrc</filename>.  Comments in the
    194 file should explain everything you need.  The comments and
     356</sect2>
     357 
     358<sect2>
     359<title><filename>~/.bashrc</filename></title>
     360
     361<para>Here is a base <filename>~/.bashrc</filename>.  The comments and
    195362instructions for using <filename class="directory">/etc/skel</filename> for
    196 <filename>.bash_profile</filename> above also apply here. Only the
    197 target file names are different.</para>
     363<filename>.bash_profile</filename> above also apply here. Only the target file
     364names are different.</para>
    198365
    199366<screen><userinput><command>cat &gt; ~/.bashrc &lt;&lt; "EOF"</command>
     
    215382# End ~/.bashrc
    216383<command>EOF</command></userinput></screen>
    217 
    218 <para>Here is a base <filename>~/.bash_logout</filename>.  Comments in
    219 the file should explain everything you need.  You will notice that the
    220 base <filename>~/.bash_logout</filename> does not include a
    221 <userinput>clear</userinput> command.  This is because the clear is
    222 handled in the <filename>/etc/issue</filename> file.</para>
     384</sect2>
     385 
     386 
     387<sect2>
     388<title><filename>~/.bash_logout</filename></title>
     389
     390<para>This is an empty <filename>~/.bash_logout</filename> that can be used as
     391a template.  You will notice that the base <filename>~/.bash_logout</filename>
     392does not include a <userinput>clear</userinput> command.  This is because the
     393clear is handled in the <filename>/etc/issue</filename> file.</para>
    223394
    224395<screen><userinput><command>cat &gt; ~/.bash_logout &lt;&lt; "EOF"</command>
     
    231402# End ~/.bash_logout
    232403<command>EOF</command></userinput></screen>
    233 
    234 <para>
    235 If you want to use the <filename>dircolors</filename> capability
    236 then run the following command. The <filename class="directory">/etc/skel</filename> setup
    237 steps seen above also can be used here to provide a
    238 <filename>.dircolors</filename> file when a new user is set up. As
    239 before, just change the output file name on the following command and
    240 assure the permissions, owner and group are correct on the files created
    241 and/or copied.
     404</sect2>
     405 
     406 
     407<sect2>
     408<title><filename>/etc/dircolors</filename></title>
     409
     410<para> If you want to use the <filename>dircolors</filename> capability then
     411run the following command. The <filename class="directory">/etc/skel</filename>
     412setup steps seen above also can be used here to provide a
     413<filename>.dircolors</filename> file when a new user is set up. As before, just
     414change the output file name on the following command and assure the
     415permissions, owner and group are correct on the files created and/or copied.
    242416</para>
    243417
    244 <para>
    245 <userinput><command>dircolors -p > /etc/dircolors</command></userinput>
    246 </para>
    247 
    248 <para>Ian Macdonald has written an excellent collection of tips and
     418<screen><userinput><command>dircolors -p > /etc/dircolors</command></userinput></screen>
     419
     420<para>If you wish to customize the colors used for different file types, you can
     421edit the <filename>/etc/dircolors</filename> file.  The instructions for setting
     422the colors are embedded in the file.</para>
     423
     424
     425<para>Finally, Ian Macdonald has written an excellent collection of tips and
    249426tricks to enhance your shell environment.  You can read it online at
    250427<ulink
    251428url="http://www.caliban.org/bash/index.shtml">http://www.caliban.org/bash/index.shtml</ulink></para>
    252 
     429</sect2>
    253430</sect1>
  • stylesheets/blfs.css

    r78349d6 r1a396398  
    5454}
    5555
     56h4 {
     57  font-size: 90%;
     58  padding-left: 1em;
     59}
     60
     61
    5662div.navheader ul li, div.navfooter ul li {
    5763        display: inline;
     
    98104tt {
    99105    font-family: courier, monospace;
     106    font-size: 110%;
    100107}
    101108
     
    108115
    109116pre.screen {
    110   padding-left: 1.5em;
     117  padding: 0.5em 1.5em;
    111118  line-height: 110%;
    112119}
Note: See TracChangeset for help on using the changeset viewer.