[f8d632ac] | 1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
| 2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
|
---|
| 3 | "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
|
---|
| 4 | <!ENTITY % general-entities SYSTEM "../../general.ent">
|
---|
| 5 | %general-entities;
|
---|
| 6 | ]>
|
---|
| 7 |
|
---|
[78b3cd61] | 8 | <sect1 id="postlfs-config-profile" xreflabel="The Bash Shell Startup Files">
|
---|
[a0f03b0] | 9 | <sect1info>
|
---|
[5cd0959d] | 10 | <othername>$LastChangedBy$</othername>
|
---|
| 11 | <date>$Date$</date>
|
---|
[a0f03b0] | 12 | </sect1info>
|
---|
[bae6e15] | 13 | <?dbhtml filename="profile.html"?>
|
---|
[b554263] | 14 | <title>The Bash Shell Startup Files</title>
|
---|
[f45b1953] | 15 |
|
---|
[b554263] | 16 | <para>The shell program <filename>/bin/bash</filename> (hereafter
|
---|
[64d97b7c] | 17 | referred to as just "the shell") uses a collection of startup files to
|
---|
[1a396398] | 18 | help create an environment. Each file has a specific use and
|
---|
[cfc2a54] | 19 | may affect login and interactive environments differently. The files in
|
---|
[99e8a229] | 20 | the <filename class="directory">/etc</filename> directory generally provide
|
---|
| 21 | global settings. If an equivalent file exists in your home directory it may
|
---|
[cfc2a54] | 22 | override the global settings.
|
---|
| 23 | </para>
|
---|
| 24 |
|
---|
| 25 | <para>An interactive login shell is started after a successful login, using
|
---|
[1a396398] | 26 | <filename>/bin/login</filename>, by reading the <filename>/etc/passwd</filename>
|
---|
| 27 | file. This shell invocation normally reads <filename>/etc/profile</filename>
|
---|
[99e8a229] | 28 | and its private equivalent <filename>~/.bash_profile</filename> upon
|
---|
| 29 | startup.</para>
|
---|
[1a396398] | 30 |
|
---|
| 31 | <para>An interactive non-login shell is normally started at the command-line
|
---|
[0990cf7a] | 32 | (e.g., <prompt>[prompt]$</prompt><command>/bin/bash</command>) or by the
|
---|
[1a396398] | 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
|
---|
[3b7081ba] | 42 | waiting for user input between commands. For these shell invocations, only
|
---|
| 43 | the environment inherited from the parent shell is used.</para>
|
---|
[1a396398] | 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 |
|
---|
[99e8a229] | 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>
|
---|
[b554263] | 52 |
|
---|
[766bbe40] | 53 | <para>For more information see <command>info bash</command> --
|
---|
| 54 | <emphasis role="strong">Nodes: Bash Startup Files and Interactive
|
---|
| 55 | Shells.</emphasis></para>
|
---|
[b554263] | 56 |
|
---|
[99e8a229] | 57 | <sect2 id="etc-profile-profile">
|
---|
[1a396398] | 58 | <title><filename>/etc/profile</filename></title>
|
---|
[99e8a229] | 59 | <indexterm zone="postlfs-config-profile etc-profile-profile">
|
---|
| 60 | <primary sortas="e-etc-profile-profile">/etc/profile</primary>
|
---|
| 61 | </indexterm>
|
---|
[cfc2a54] | 62 |
|
---|
[1a396398] | 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>
|
---|
[b554263] | 70 |
|
---|
[1a396398] | 71 | <para>For more information on the escape sequences you can use for your prompt
|
---|
[0990cf7a] | 72 | (e.g., the <envar>PS1</envar> environment variable) see <command>info
|
---|
[766bbe40] | 73 | bash</command> -- <emphasis role="strong">Node: Printing a
|
---|
| 74 | Prompt.</emphasis></para>
|
---|
[b554263] | 75 |
|
---|
[766bbe40] | 76 | <screen><userinput><command>cat > /etc/profile << "EOF"</command>
|
---|
| 77 | # Begin /etc/profile
|
---|
[b554263] | 78 | # Written for Beyond Linux From Scratch
|
---|
| 79 | # by James Robertson <jameswrobertson@earthlink.net>
|
---|
[1a396398] | 80 | # modifications by Dagmar d'Surreal <rivyqntzne@pbzpnfg.arg>
|
---|
| 81 |
|
---|
[b554263] | 82 | # System wide environment variables and startup programs.
|
---|
[1a396398] | 83 |
|
---|
[b554263] | 84 | # System wide aliases and functions should go in /etc/bashrc. Personal
|
---|
| 85 | # environment variables and startup programs should go into
|
---|
| 86 | # ~/.bash_profile. Personal aliases and functions should go into
|
---|
| 87 | # ~/.bashrc.
|
---|
[1a396398] | 88 |
|
---|
| 89 | # Functions to help us manage paths. Second argument is the name of the
|
---|
| 90 | # path variable to be modified (default: PATH)
|
---|
| 91 | pathremove () {
|
---|
| 92 | local IFS=':'
|
---|
| 93 | local NEWPATH
|
---|
| 94 | local DIR
|
---|
| 95 | local PATHVARIABLE=${2:-PATH}
|
---|
| 96 | for DIR in ${!PATHVARIABLE} ; do
|
---|
| 97 | if [ "$DIR" != "$1" ] ; then
|
---|
| 98 | NEWPATH=${NEWPATH:+$NEWPATH:}$DIR
|
---|
| 99 | fi
|
---|
| 100 | done
|
---|
| 101 | export $PATHVARIABLE="$NEWPATH"
|
---|
[b554263] | 102 | }
|
---|
[1a396398] | 103 |
|
---|
| 104 | pathprepend () {
|
---|
| 105 | pathremove $1 $2
|
---|
| 106 | local PATHVARIABLE=${2:-PATH}
|
---|
| 107 | export $PATHVARIABLE="$1${!PATHVARIABLE:+:${!PATHVARIABLE}}"
|
---|
| 108 | }
|
---|
| 109 |
|
---|
| 110 | pathappend () {
|
---|
| 111 | pathremove $1 $2
|
---|
| 112 | local PATHVARIABLE=${2:-PATH}
|
---|
| 113 | export $PATHVARIABLE="${!PATHVARIABLE:+${!PATHVARIABLE}:}$1"
|
---|
| 114 | }
|
---|
| 115 |
|
---|
[e9ef7b5e] | 116 |
|
---|
| 117 | # Set the initial path
|
---|
| 118 | export PATH=/bin:/usr/bin
|
---|
| 119 |
|
---|
[1a396398] | 120 | if [ $EUID -eq 0 ] ; then
|
---|
[e9ef7b5e] | 121 | pathappend /sbin:/usr/sbin
|
---|
[1a396398] | 122 | unset HISTFILE
|
---|
[b554263] | 123 | fi
|
---|
[1a396398] | 124 |
|
---|
| 125 | # Setup some environment variables.
|
---|
| 126 | export HISTSIZE=1000
|
---|
| 127 | export HISTIGNORE="&:[bf]g:exit"
|
---|
| 128 | #export PS1="[\u@\h \w]\\$ "
|
---|
| 129 | export PS1='\u@\h:\w\$ '
|
---|
| 130 |
|
---|
| 131 | for script in /etc/profile.d/*.sh ; do
|
---|
[d3880c0] | 132 | if [ -r $script ] ; then
|
---|
[1a396398] | 133 | . $script
|
---|
| 134 | fi
|
---|
| 135 | done
|
---|
| 136 |
|
---|
[99e8a229] | 137 | # Now to clean up
|
---|
[1a396398] | 138 | unset pathremove pathprepend pathappend
|
---|
| 139 |
|
---|
| 140 | # End /etc/profile
|
---|
| 141 | <command>EOF</command></userinput></screen>
|
---|
| 142 |
|
---|
[99e8a229] | 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>
|
---|
[1a396398] | 150 |
|
---|
| 151 | <screen><userinput><command>install --directory --mode=0755 --owner=root --group=root /etc/profile.d</command></userinput></screen>
|
---|
[99e8a229] | 152 | </sect3>
|
---|
[1a396398] | 153 |
|
---|
[99e8a229] | 154 | <sect3 id="etc-profile.d-dircolors.sh">
|
---|
[1a396398] | 155 | <title><filename>/etc/profile.d/dircolors.sh</filename></title>
|
---|
[99e8a229] | 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>
|
---|
[1a396398] | 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
|
---|
[99e8a229] | 165 | end of this section.</para>
|
---|
[1a396398] | 166 |
|
---|
| 167 | <screen><userinput><command>cat > /etc/profile.d/dircolors.sh << "EOF"</command>
|
---|
| 168 | # Setup for /bin/ls to support color, the alias is in /etc/bashrc.
|
---|
| 169 | if [ -f "/etc/dircolors" ] ; then
|
---|
| 170 | eval $(dircolors -b /etc/dircolors)
|
---|
| 171 |
|
---|
| 172 | if [ -f "$HOME/.dircolors" ] ; then
|
---|
| 173 | eval $(dircolors -b $HOME/.dircolors)
|
---|
| 174 | fi
|
---|
[b554263] | 175 | fi
|
---|
[1a396398] | 176 | alias ls='ls --color=auto'
|
---|
| 177 | <command>EOF</command></userinput></screen>
|
---|
| 178 | </sect3>
|
---|
| 179 |
|
---|
[99e8a229] | 180 | <sect3 id="extrapaths.sh">
|
---|
[1a396398] | 181 | <title><filename>/etc/profile.d/extrapaths.sh</filename></title>
|
---|
[99e8a229] | 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>
|
---|
[1a396398] | 186 |
|
---|
| 187 | <para>This script adds several useful paths to the <envar>PATH</envar> and
|
---|
[99e8a229] | 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>
|
---|
[1a396398] | 193 |
|
---|
| 194 | <screen><userinput><command>cat > /etc/profile.d/extrapaths.sh << "EOF"</command>
|
---|
| 195 | if [ -d /usr/local/lib/pkgconfig ] ; then
|
---|
| 196 | pathappend /usr/local/lib/pkgconfig PKG_CONFIG_PATH
|
---|
| 197 | fi
|
---|
| 198 | if [ -d /usr/local/bin ]; then
|
---|
| 199 | pathprepend /usr/local/bin
|
---|
[b554263] | 200 | fi
|
---|
[1a396398] | 201 | if [ -d /usr/local/sbin -a $EUID -eq 0 ]; then
|
---|
| 202 | pathprepend /usr/local/sbin
|
---|
| 203 | fi
|
---|
[d3880c0] | 204 | for directory in $(find /opt/*/lib/pkgconfig -type d 2>/dev/null); do
|
---|
[1a396398] | 205 | pathappend $directory PKG_CONFIG_PATH
|
---|
| 206 | done
|
---|
[d3880c0] | 207 | for directory in $(find /opt/*/bin -type d 2>/dev/null); do
|
---|
[1a396398] | 208 | pathappend $directory
|
---|
| 209 | done
|
---|
| 210 | if [ -d ~/bin ]; then
|
---|
| 211 | pathprepend ~/bin
|
---|
| 212 | fi
|
---|
| 213 | #if [ $EUID -gt 99 ]; then
|
---|
| 214 | # pathappend .
|
---|
| 215 | #fi
|
---|
| 216 | <command>EOF</command></userinput></screen>
|
---|
| 217 | </sect3>
|
---|
[b554263] | 218 |
|
---|
[99e8a229] | 219 | <sect3 id="readline.sh">
|
---|
[1a396398] | 220 | <title><filename>/etc/profile.d/readline.sh</filename></title>
|
---|
[99e8a229] | 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>
|
---|
[b554263] | 225 |
|
---|
[99e8a229] | 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>
|
---|
[1a396398] | 229 |
|
---|
| 230 | <screen><userinput><command>cat > /etc/profile.d/readline.sh << "EOF"</command>
|
---|
[b554263] | 231 | # Setup the INPUTRC environment variable.
|
---|
| 232 | if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ] ; then
|
---|
[1a396398] | 233 | INPUTRC=/etc/inputrc
|
---|
[b554263] | 234 | fi
|
---|
[1a396398] | 235 | export INPUTRC
|
---|
| 236 | <command>EOF</command></userinput></screen>
|
---|
| 237 | </sect3>
|
---|
[b554263] | 238 |
|
---|
[99e8a229] | 239 | <sect3 id="tinker-term.sh">
|
---|
[1a396398] | 240 | <title><filename>/etc/profile.d/tinker-term.sh</filename></title>
|
---|
[99e8a229] | 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>
|
---|
[b554263] | 245 |
|
---|
[99e8a229] | 246 | <para>Some applications need a specific <envar>TERM</envar> setting to support
|
---|
| 247 | color.</para>
|
---|
[1a396398] | 248 |
|
---|
| 249 | <screen><userinput><command>cat > /etc/profile.d/tinker-term.sh << "EOF"</command>
|
---|
[dd362e5] | 250 | # This will tinker with the value of TERM in order to convince certain
|
---|
| 251 | # apps that we can, indeed, display color in their window.
|
---|
[1a396398] | 252 |
|
---|
| 253 | if [ -n "$COLORTERM" ]; then
|
---|
| 254 | export TERM=xterm-color
|
---|
| 255 | fi
|
---|
| 256 |
|
---|
| 257 | if [ "$TERM" = "xterm" ]; then
|
---|
| 258 | export TERM=xterm-color
|
---|
[b554263] | 259 | fi
|
---|
[1a396398] | 260 | <command>EOF</command></userinput></screen>
|
---|
| 261 | </sect3>
|
---|
[b554263] | 262 |
|
---|
[99e8a229] | 263 | <sect3 id="umask.sh">
|
---|
[1a396398] | 264 | <title><filename>/etc/profile.d/umask.sh</filename></title>
|
---|
[99e8a229] | 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>
|
---|
[1a396398] | 269 |
|
---|
[99e8a229] | 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>
|
---|
[b554263] | 273 |
|
---|
[1a396398] | 274 | <screen><userinput><command>cat > /etc/profile.d/umask.sh << "EOF"</command>
|
---|
| 275 | # By default we want the umask to get set.
|
---|
| 276 | if [ "$(id -gn)" = "$(id -un)" -a $EUID -gt 99 ] ; then
|
---|
| 277 | umask 002
|
---|
| 278 | else
|
---|
| 279 | umask 022
|
---|
| 280 | fi
|
---|
| 281 | <command>EOF</command></userinput></screen>
|
---|
| 282 | </sect3>
|
---|
| 283 |
|
---|
[99e8a229] | 284 | <sect3 id="X.sh">
|
---|
[1a396398] | 285 | <title><filename>/etc/profile.d/X.sh</filename></title>
|
---|
[99e8a229] | 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>
|
---|
[1a396398] | 290 |
|
---|
[99e8a229] | 291 | <para>If <application>X</application> is installed, the <envar>PATH</envar>
|
---|
| 292 | and <envar>PKG_CONFIG_PATH</envar> variables are also updated.</para>
|
---|
[1a396398] | 293 |
|
---|
| 294 | <screen><userinput><command>cat > /etc/profile.d/X.sh << "EOF"</command>
|
---|
| 295 | if [ -x /usr/X11R6/bin/X ]; then
|
---|
| 296 | pathappend /usr/X11R6/bin
|
---|
| 297 | fi
|
---|
| 298 | if [ -d /usr/X11R6/lib/pkgconfig ] ; then
|
---|
| 299 | pathappend /usr/X11R6/lib/pkgconfig PKG_CONFIG_PATH
|
---|
| 300 | fi
|
---|
| 301 | <command>EOF</command></userinput></screen>
|
---|
| 302 | </sect3>
|
---|
| 303 |
|
---|
[99e8a229] | 304 | <sect3 id="titlebars.sh">
|
---|
[1a396398] | 305 | <title><filename>/etc/profile.d/xterm-titlebars.sh</filename></title>
|
---|
[99e8a229] | 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>
|
---|
[1a396398] | 316 |
|
---|
| 317 | <screen><userinput><command>cat > /etc/profile.d/xterm-titlebars.sh << "EOF"</command>
|
---|
[dd362e5] | 318 | # The substring match ensures this works for "xterm" and "xterm-xfree86".
|
---|
[1a396398] | 319 | if [ "${TERM:0:5}" = "xterm" ]; then
|
---|
| 320 | PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME} : ${PWD}\007"'
|
---|
| 321 | export PROMPT_COMMAND
|
---|
| 322 | fi
|
---|
[766bbe40] | 323 | <command>EOF</command></userinput></screen>
|
---|
[0ca9f97] | 324 | </sect3>
|
---|
| 325 |
|
---|
[99e8a229] | 326 | <sect3 id="i18n.sh">
|
---|
[0ca9f97] | 327 | <title><filename>/etc/profile.d/i18n.sh</filename></title>
|
---|
[99e8a229] | 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>
|
---|
[0ca9f97] | 332 |
|
---|
| 333 | <para>This script shows how to set some environment variables necessary for
|
---|
[d295e92] | 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 – 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
|
---|
[0ca9f97] | 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 |
|
---|
[d295e92] | 364 | <para>After you are sure about your locale settings, create the
|
---|
[0ca9f97] | 365 | <filename>/etc/profile.d/i18n.sh</filename> file:</para>
|
---|
| 366 |
|
---|
| 367 | <screen><userinput><command>cat > /etc/profile.d/i18n.sh << "EOF"</command>
|
---|
| 368 | # Set up i18n variables
|
---|
[d295e92] | 369 | export LC_ALL=<replaceable>[ll]</replaceable>_<replaceable>[CC]</replaceable>
|
---|
| 370 | export LANG=<replaceable>[ll]</replaceable>_<replaceable>[CC]</replaceable>
|
---|
[ad59f9e2] | 371 | export G_FILENAME_ENCODING=@locale
|
---|
[0ca9f97] | 372 | <command>EOF</command></userinput></screen>
|
---|
[b554263] | 373 |
|
---|
[99e8a229] | 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>
|
---|
[ad59f9e2] | 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>
|
---|
[11fcaea2] | 384 | </sect3>
|
---|
[d295e92] | 385 |
|
---|
| 386 | <sect3>
|
---|
| 387 | <title><filename>Other initialization values</filename></title>
|
---|
| 388 |
|
---|
[99e8a229] | 389 | <para>Other initialization can easily be added to the
|
---|
| 390 | <filename>profile</filename> by adding additional scripts to the
|
---|
[1a396398] | 391 | <filename class='directory'>/etc/profile.d</filename> directory.</para>
|
---|
| 392 | </sect3>
|
---|
[0ca9f97] | 393 |
|
---|
[1a396398] | 394 | </sect2>
|
---|
| 395 |
|
---|
[99e8a229] | 396 | <sect2 id="etc-bashrc-profile">
|
---|
[1a396398] | 397 | <title><filename>/etc/bashrc</filename></title>
|
---|
[99e8a229] | 398 | <indexterm zone="postlfs-config-profile etc-bashrc-profile">
|
---|
| 399 | <primary
|
---|
| 400 | sortas="e-etc-bashrc-profile">/etc/bashrc</primary>
|
---|
| 401 | </indexterm>
|
---|
| 402 |
|
---|
[b554263] | 403 | <para>Here is a base <filename>/etc/bashrc</filename>. Comments in the
|
---|
| 404 | file should explain everything you need.</para>
|
---|
| 405 |
|
---|
[766bbe40] | 406 | <screen><userinput><command>cat > /etc/bashrc << "EOF"</command>
|
---|
| 407 | # Begin /etc/bashrc
|
---|
[b554263] | 408 | # Written for Beyond Linux From Scratch
|
---|
| 409 | # by James Robertson <jameswrobertson@earthlink.net>
|
---|
[ad33bab6] | 410 | # updated by Bruce Dubbs <bdubbs@linuxfromscratch.org>
|
---|
| 411 |
|
---|
| 412 | # Make sure that the terminal is set up properly for each shell
|
---|
| 413 |
|
---|
| 414 | if [ -f /etc/profile.d/tinker-term.sh ]; then
|
---|
| 415 | source /etc/profile.d/tinker-term.sh
|
---|
| 416 | fi
|
---|
| 417 |
|
---|
| 418 | if [ -f /etc/profile.d/xterm-titlebars.sh ]; then
|
---|
| 419 | source /etc/profile.d/xterm-titlebars.sh
|
---|
| 420 | fi
|
---|
[b554263] | 421 |
|
---|
| 422 | # System wide aliases and functions.
|
---|
| 423 |
|
---|
| 424 | # System wide environment variables and startup programs should go into
|
---|
| 425 | # /etc/profile. Personal environment variables and startup programs
|
---|
| 426 | # should go into ~/.bash_profile. Personal aliases and functions should
|
---|
| 427 | # go into ~/.bashrc
|
---|
| 428 |
|
---|
| 429 | # Provides a colored /bin/ls command. Used in conjunction with code in
|
---|
| 430 | # /etc/profile.
|
---|
[1a396398] | 431 |
|
---|
[b554263] | 432 | alias ls='ls --color=auto'
|
---|
| 433 |
|
---|
[1a396398] | 434 | # Provides prompt for non-login shells, specifically shells started
|
---|
| 435 | # in the <application>X</application> environment. [Review the LFS archive thread titled
|
---|
[dd362e5] | 436 | # PS1 Environment Variable for a great case study behind this script
|
---|
| 437 | # addendum.]
|
---|
[1a396398] | 438 |
|
---|
[3383489] | 439 | #export PS1="[\u@\h \w]\\$ "
|
---|
| 440 | export PS1='\u@\h:\w\$ '
|
---|
[28a9992] | 441 |
|
---|
[766bbe40] | 442 | # End /etc/bashrc
|
---|
| 443 | <command>EOF</command></userinput></screen>
|
---|
[1a396398] | 444 | </sect2>
|
---|
| 445 |
|
---|
[99e8a229] | 446 | <sect2 id="bash_profile-profile">
|
---|
[1a396398] | 447 | <title><filename>~/.bash_profile</filename></title>
|
---|
[99e8a229] | 448 | <indexterm zone="postlfs-config-profile bash_profile-profile">
|
---|
| 449 | <primary sortas="e-AA.bash_profile-profile">~/.bash_profile</primary>
|
---|
| 450 | </indexterm>
|
---|
[b554263] | 451 |
|
---|
[1a396398] | 452 | <para>Here is a base <filename>~/.bash_profile</filename>. If you want each
|
---|
| 453 | new user to have this file automatically, just change the output of
|
---|
| 454 | the command to <filename>/etc/skel/.bash_profile</filename> and check the
|
---|
[cfc2a54] | 455 | permissions after the command is run. You can then copy
|
---|
[1a396398] | 456 | <filename>/etc/skel/.bash_profile</filename> to the home directories of already
|
---|
| 457 | existing users, including root, and set the owner and group appropriately.
|
---|
[cfc2a54] | 458 | </para>
|
---|
[b554263] | 459 |
|
---|
[766bbe40] | 460 | <screen><userinput><command>cat > ~/.bash_profile << "EOF"</command>
|
---|
| 461 | # Begin ~/.bash_profile
|
---|
[b554263] | 462 | # Written for Beyond Linux From Scratch
|
---|
| 463 | # by James Robertson <jameswrobertson@earthlink.net>
|
---|
[1a396398] | 464 | # updated by Bruce Dubbs <bdubbs@linuxfromscratch.org>
|
---|
[b554263] | 465 |
|
---|
[64d97b7c] | 466 | # Personal environment variables and startup programs.
|
---|
[b554263] | 467 |
|
---|
| 468 | # Personal aliases and functions should go in ~/.bashrc. System wide
|
---|
| 469 | # environment variables and startup programs are in /etc/profile.
|
---|
| 470 | # System wide aliases and functions are in /etc/bashrc.
|
---|
| 471 |
|
---|
[1a396398] | 472 | append () {
|
---|
| 473 | # First remove the directory
|
---|
| 474 | local IFS=':'
|
---|
| 475 | local NEWPATH
|
---|
| 476 | for DIR in $PATH; do
|
---|
| 477 | if [ "$DIR" != "$1" ]; then
|
---|
[3f1b51a] | 478 | NEWPATH=${NEWPATH:+$NEWPATH:}$DIR
|
---|
[1a396398] | 479 | fi
|
---|
| 480 | done
|
---|
| 481 |
|
---|
| 482 | # Then append the directory
|
---|
| 483 | export PATH=$NEWPATH:$1
|
---|
| 484 | }
|
---|
| 485 |
|
---|
[b554263] | 486 | if [ -f "$HOME/.bashrc" ] ; then
|
---|
[7008de1] | 487 | source $HOME/.bashrc
|
---|
[b554263] | 488 | fi
|
---|
| 489 |
|
---|
| 490 | if [ -d "$HOME/bin" ] ; then
|
---|
[1a396398] | 491 | append $HOME/bin
|
---|
[b554263] | 492 | fi
|
---|
| 493 |
|
---|
[1a396398] | 494 | unset append
|
---|
[b554263] | 495 |
|
---|
[766bbe40] | 496 | # End ~/.bash_profile
|
---|
| 497 | <command>EOF</command></userinput></screen>
|
---|
[1a396398] | 498 | </sect2>
|
---|
| 499 |
|
---|
[99e8a229] | 500 | <sect2 id="bashrc-profile">
|
---|
[1a396398] | 501 | <title><filename>~/.bashrc</filename></title>
|
---|
[99e8a229] | 502 | <indexterm zone="postlfs-config-profile bashrc-profile">
|
---|
| 503 | <primary sortas="e-AA.bashrc-profile">~/.bashrc</primary>
|
---|
| 504 | </indexterm>
|
---|
[b554263] | 505 |
|
---|
[1a396398] | 506 | <para>Here is a base <filename>~/.bashrc</filename>. The comments and
|
---|
[8604d92f] | 507 | instructions for using <filename class="directory">/etc/skel</filename> for
|
---|
[1a396398] | 508 | <filename>.bash_profile</filename> above also apply here. Only the target file
|
---|
| 509 | names are different.</para>
|
---|
[b554263] | 510 |
|
---|
[766bbe40] | 511 | <screen><userinput><command>cat > ~/.bashrc << "EOF"</command>
|
---|
| 512 | # Begin ~/.bashrc
|
---|
[b554263] | 513 | # Written for Beyond Linux From Scratch
|
---|
| 514 | # by James Robertson <jameswrobertson@earthlink.net>
|
---|
| 515 |
|
---|
| 516 | # Personal aliases and functions.
|
---|
| 517 |
|
---|
| 518 | # Personal environment variables and startup programs should go in
|
---|
[64d97b7c] | 519 | # ~/.bash_profile. System wide environment variables and startup
|
---|
[b554263] | 520 | # programs are in /etc/profile. System wide aliases and functions are
|
---|
| 521 | # in /etc/bashrc.
|
---|
| 522 |
|
---|
| 523 | if [ -f "/etc/bashrc" ] ; then
|
---|
[7008de1] | 524 | source /etc/bashrc
|
---|
[b554263] | 525 | fi
|
---|
| 526 |
|
---|
[766bbe40] | 527 | # End ~/.bashrc
|
---|
| 528 | <command>EOF</command></userinput></screen>
|
---|
[1a396398] | 529 | </sect2>
|
---|
| 530 |
|
---|
| 531 |
|
---|
[99e8a229] | 532 | <sect2 id="bash_logout-profile">
|
---|
[1a396398] | 533 | <title><filename>~/.bash_logout</filename></title>
|
---|
[99e8a229] | 534 | <indexterm zone="postlfs-config-profile bash_logout-profile">
|
---|
| 535 | <primary sortas="e-AA.bash_logout-profile">~/.bash_logout</primary>
|
---|
| 536 | </indexterm>
|
---|
[b554263] | 537 |
|
---|
[1a396398] | 538 | <para>This is an empty <filename>~/.bash_logout</filename> that can be used as
|
---|
| 539 | a template. You will notice that the base <filename>~/.bash_logout</filename>
|
---|
| 540 | does not include a <userinput>clear</userinput> command. This is because the
|
---|
| 541 | clear is handled in the <filename>/etc/issue</filename> file.</para>
|
---|
[b554263] | 542 |
|
---|
[766bbe40] | 543 | <screen><userinput><command>cat > ~/.bash_logout << "EOF"</command>
|
---|
| 544 | # Begin ~/.bash_logout
|
---|
[b554263] | 545 | # Written for Beyond Linux From Scratch
|
---|
| 546 | # by James Robertson <jameswrobertson@earthlink.net>
|
---|
| 547 |
|
---|
| 548 | # Personal items to perform on logout.
|
---|
| 549 |
|
---|
[766bbe40] | 550 | # End ~/.bash_logout
|
---|
| 551 | <command>EOF</command></userinput></screen>
|
---|
[1a396398] | 552 | </sect2>
|
---|
| 553 |
|
---|
| 554 |
|
---|
[99e8a229] | 555 | <sect2 id="etc-dircolors-profile">
|
---|
[1a396398] | 556 | <title><filename>/etc/dircolors</filename></title>
|
---|
[99e8a229] | 557 | <indexterm zone="postlfs-config-profile etc-dircolors-profile">
|
---|
| 558 | <primary sortas="e-etc-dircolors-profile">/etc/dircolors</primary>
|
---|
| 559 | </indexterm>
|
---|
| 560 | <indexterm zone="postlfs-config-profile etc-dircolors-profile">
|
---|
| 561 | <primary sortas="e-AA.dircolors-profile">~/.dircolors</primary>
|
---|
| 562 | </indexterm>
|
---|
[1a396398] | 563 |
|
---|
[3b7081ba] | 564 | <para> If you want to use the <filename>dircolors</filename> capability, then
|
---|
[1a396398] | 565 | run the following command. The <filename class="directory">/etc/skel</filename>
|
---|
| 566 | setup steps seen above also can be used here to provide a
|
---|
[99e8a229] | 567 | <filename>~/.dircolors</filename> file when a new user is set up. As before,
|
---|
| 568 | just change the output file name on the following command and assure the
|
---|
[692e12c] | 569 | permissions, owner, and group are correct on the files created and/or copied.
|
---|
[cfc2a54] | 570 | </para>
|
---|
| 571 |
|
---|
[1a396398] | 572 | <screen><userinput><command>dircolors -p > /etc/dircolors</command></userinput></screen>
|
---|
[b554263] | 573 |
|
---|
[1a396398] | 574 | <para>If you wish to customize the colors used for different file types, you can
|
---|
| 575 | edit the <filename>/etc/dircolors</filename> file. The instructions for setting
|
---|
| 576 | the colors are embedded in the file.</para>
|
---|
| 577 |
|
---|
| 578 |
|
---|
| 579 | <para>Finally, Ian Macdonald has written an excellent collection of tips and
|
---|
[7008de1] | 580 | tricks to enhance your shell environment. You can read it online at
|
---|
[99e8a229] | 581 | <ulink
|
---|
| 582 | url="http://www.caliban.org/bash/index.shtml">
|
---|
| 583 | http://www.caliban.org/bash/index.shtml</ulink>.</para>
|
---|
[1a396398] | 584 | </sect2>
|
---|
[b554263] | 585 | </sect1>
|
---|