[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">
|
---|
[6a2bce2] | 60 | <primary sortas="e-etc-profile">/etc/profile</primary>
|
---|
[99e8a229] | 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">
|
---|
[6a2bce2] | 399 | <primary sortas="e-etc-bashrc">/etc/bashrc</primary>
|
---|
[99e8a229] | 400 | </indexterm>
|
---|
| 401 |
|
---|
[b554263] | 402 | <para>Here is a base <filename>/etc/bashrc</filename>. Comments in the
|
---|
| 403 | file should explain everything you need.</para>
|
---|
| 404 |
|
---|
[766bbe40] | 405 | <screen><userinput><command>cat > /etc/bashrc << "EOF"</command>
|
---|
| 406 | # Begin /etc/bashrc
|
---|
[b554263] | 407 | # Written for Beyond Linux From Scratch
|
---|
| 408 | # by James Robertson <jameswrobertson@earthlink.net>
|
---|
[ad33bab6] | 409 | # updated by Bruce Dubbs <bdubbs@linuxfromscratch.org>
|
---|
| 410 |
|
---|
| 411 | # Make sure that the terminal is set up properly for each shell
|
---|
| 412 |
|
---|
| 413 | if [ -f /etc/profile.d/tinker-term.sh ]; then
|
---|
| 414 | source /etc/profile.d/tinker-term.sh
|
---|
| 415 | fi
|
---|
| 416 |
|
---|
| 417 | if [ -f /etc/profile.d/xterm-titlebars.sh ]; then
|
---|
| 418 | source /etc/profile.d/xterm-titlebars.sh
|
---|
| 419 | fi
|
---|
[b554263] | 420 |
|
---|
| 421 | # System wide aliases and functions.
|
---|
| 422 |
|
---|
| 423 | # System wide environment variables and startup programs should go into
|
---|
| 424 | # /etc/profile. Personal environment variables and startup programs
|
---|
| 425 | # should go into ~/.bash_profile. Personal aliases and functions should
|
---|
| 426 | # go into ~/.bashrc
|
---|
| 427 |
|
---|
| 428 | # Provides a colored /bin/ls command. Used in conjunction with code in
|
---|
| 429 | # /etc/profile.
|
---|
[1a396398] | 430 |
|
---|
[b554263] | 431 | alias ls='ls --color=auto'
|
---|
| 432 |
|
---|
[1a396398] | 433 | # Provides prompt for non-login shells, specifically shells started
|
---|
| 434 | # in the <application>X</application> environment. [Review the LFS archive thread titled
|
---|
[dd362e5] | 435 | # PS1 Environment Variable for a great case study behind this script
|
---|
| 436 | # addendum.]
|
---|
[1a396398] | 437 |
|
---|
[3383489] | 438 | #export PS1="[\u@\h \w]\\$ "
|
---|
| 439 | export PS1='\u@\h:\w\$ '
|
---|
[28a9992] | 440 |
|
---|
[766bbe40] | 441 | # End /etc/bashrc
|
---|
| 442 | <command>EOF</command></userinput></screen>
|
---|
[1a396398] | 443 | </sect2>
|
---|
| 444 |
|
---|
[99e8a229] | 445 | <sect2 id="bash_profile-profile">
|
---|
[1a396398] | 446 | <title><filename>~/.bash_profile</filename></title>
|
---|
[99e8a229] | 447 | <indexterm zone="postlfs-config-profile bash_profile-profile">
|
---|
[6a2bce2] | 448 | <primary sortas="e-AA.bash_profile">~/.bash_profile</primary>
|
---|
[99e8a229] | 449 | </indexterm>
|
---|
[b554263] | 450 |
|
---|
[1a396398] | 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
|
---|
[cfc2a54] | 454 | permissions after the command is run. You can then copy
|
---|
[1a396398] | 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.
|
---|
[cfc2a54] | 457 | </para>
|
---|
[b554263] | 458 |
|
---|
[766bbe40] | 459 | <screen><userinput><command>cat > ~/.bash_profile << "EOF"</command>
|
---|
| 460 | # Begin ~/.bash_profile
|
---|
[b554263] | 461 | # Written for Beyond Linux From Scratch
|
---|
| 462 | # by James Robertson <jameswrobertson@earthlink.net>
|
---|
[1a396398] | 463 | # updated by Bruce Dubbs <bdubbs@linuxfromscratch.org>
|
---|
[b554263] | 464 |
|
---|
[64d97b7c] | 465 | # Personal environment variables and startup programs.
|
---|
[b554263] | 466 |
|
---|
| 467 | # Personal aliases and functions should go in ~/.bashrc. System wide
|
---|
| 468 | # environment variables and startup programs are in /etc/profile.
|
---|
| 469 | # System wide aliases and functions are in /etc/bashrc.
|
---|
| 470 |
|
---|
[1a396398] | 471 | append () {
|
---|
| 472 | # First remove the directory
|
---|
| 473 | local IFS=':'
|
---|
| 474 | local NEWPATH
|
---|
| 475 | for DIR in $PATH; do
|
---|
| 476 | if [ "$DIR" != "$1" ]; then
|
---|
[3f1b51a] | 477 | NEWPATH=${NEWPATH:+$NEWPATH:}$DIR
|
---|
[1a396398] | 478 | fi
|
---|
| 479 | done
|
---|
| 480 |
|
---|
| 481 | # Then append the directory
|
---|
| 482 | export PATH=$NEWPATH:$1
|
---|
| 483 | }
|
---|
| 484 |
|
---|
[b554263] | 485 | if [ -f "$HOME/.bashrc" ] ; then
|
---|
[7008de1] | 486 | source $HOME/.bashrc
|
---|
[b554263] | 487 | fi
|
---|
| 488 |
|
---|
| 489 | if [ -d "$HOME/bin" ] ; then
|
---|
[1a396398] | 490 | append $HOME/bin
|
---|
[b554263] | 491 | fi
|
---|
| 492 |
|
---|
[1a396398] | 493 | unset append
|
---|
[b554263] | 494 |
|
---|
[766bbe40] | 495 | # End ~/.bash_profile
|
---|
| 496 | <command>EOF</command></userinput></screen>
|
---|
[1a396398] | 497 | </sect2>
|
---|
| 498 |
|
---|
[99e8a229] | 499 | <sect2 id="bashrc-profile">
|
---|
[1a396398] | 500 | <title><filename>~/.bashrc</filename></title>
|
---|
[99e8a229] | 501 | <indexterm zone="postlfs-config-profile bashrc-profile">
|
---|
[6a2bce2] | 502 | <primary sortas="e-AA.bashrc">~/.bashrc</primary>
|
---|
[99e8a229] | 503 | </indexterm>
|
---|
[b554263] | 504 |
|
---|
[1a396398] | 505 | <para>Here is a base <filename>~/.bashrc</filename>. The comments and
|
---|
[8604d92f] | 506 | instructions for using <filename class="directory">/etc/skel</filename> for
|
---|
[1a396398] | 507 | <filename>.bash_profile</filename> above also apply here. Only the target file
|
---|
| 508 | names are different.</para>
|
---|
[b554263] | 509 |
|
---|
[766bbe40] | 510 | <screen><userinput><command>cat > ~/.bashrc << "EOF"</command>
|
---|
| 511 | # Begin ~/.bashrc
|
---|
[b554263] | 512 | # Written for Beyond Linux From Scratch
|
---|
| 513 | # by James Robertson <jameswrobertson@earthlink.net>
|
---|
| 514 |
|
---|
| 515 | # Personal aliases and functions.
|
---|
| 516 |
|
---|
| 517 | # Personal environment variables and startup programs should go in
|
---|
[64d97b7c] | 518 | # ~/.bash_profile. System wide environment variables and startup
|
---|
[b554263] | 519 | # programs are in /etc/profile. System wide aliases and functions are
|
---|
| 520 | # in /etc/bashrc.
|
---|
| 521 |
|
---|
| 522 | if [ -f "/etc/bashrc" ] ; then
|
---|
[7008de1] | 523 | source /etc/bashrc
|
---|
[b554263] | 524 | fi
|
---|
| 525 |
|
---|
[766bbe40] | 526 | # End ~/.bashrc
|
---|
| 527 | <command>EOF</command></userinput></screen>
|
---|
[1a396398] | 528 | </sect2>
|
---|
| 529 |
|
---|
| 530 |
|
---|
[99e8a229] | 531 | <sect2 id="bash_logout-profile">
|
---|
[1a396398] | 532 | <title><filename>~/.bash_logout</filename></title>
|
---|
[99e8a229] | 533 | <indexterm zone="postlfs-config-profile bash_logout-profile">
|
---|
[6a2bce2] | 534 | <primary sortas="e-AA.bash_logout">~/.bash_logout</primary>
|
---|
[99e8a229] | 535 | </indexterm>
|
---|
[b554263] | 536 |
|
---|
[1a396398] | 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>
|
---|
[b554263] | 541 |
|
---|
[766bbe40] | 542 | <screen><userinput><command>cat > ~/.bash_logout << "EOF"</command>
|
---|
| 543 | # Begin ~/.bash_logout
|
---|
[b554263] | 544 | # Written for Beyond Linux From Scratch
|
---|
| 545 | # by James Robertson <jameswrobertson@earthlink.net>
|
---|
| 546 |
|
---|
| 547 | # Personal items to perform on logout.
|
---|
| 548 |
|
---|
[766bbe40] | 549 | # End ~/.bash_logout
|
---|
| 550 | <command>EOF</command></userinput></screen>
|
---|
[1a396398] | 551 | </sect2>
|
---|
| 552 |
|
---|
| 553 |
|
---|
[99e8a229] | 554 | <sect2 id="etc-dircolors-profile">
|
---|
[1a396398] | 555 | <title><filename>/etc/dircolors</filename></title>
|
---|
[99e8a229] | 556 | <indexterm zone="postlfs-config-profile etc-dircolors-profile">
|
---|
[6a2bce2] | 557 | <primary sortas="e-etc-dircolors">/etc/dircolors</primary>
|
---|
[99e8a229] | 558 | </indexterm>
|
---|
| 559 | <indexterm zone="postlfs-config-profile etc-dircolors-profile">
|
---|
[6a2bce2] | 560 | <primary sortas="e-AA.dircolors">~/.dircolors</primary>
|
---|
[99e8a229] | 561 | </indexterm>
|
---|
[1a396398] | 562 |
|
---|
[3b7081ba] | 563 | <para> If you want to use the <filename>dircolors</filename> capability, then
|
---|
[1a396398] | 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
|
---|
[99e8a229] | 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
|
---|
[692e12c] | 568 | permissions, owner, and group are correct on the files created and/or copied.
|
---|
[cfc2a54] | 569 | </para>
|
---|
| 570 |
|
---|
[1a396398] | 571 | <screen><userinput><command>dircolors -p > /etc/dircolors</command></userinput></screen>
|
---|
[b554263] | 572 |
|
---|
[1a396398] | 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
|
---|
[7008de1] | 579 | tricks to enhance your shell environment. You can read it online at
|
---|
[99e8a229] | 580 | <ulink
|
---|
| 581 | url="http://www.caliban.org/bash/index.shtml">
|
---|
| 582 | http://www.caliban.org/bash/index.shtml</ulink>.</para>
|
---|
[1a396398] | 583 | </sect2>
|
---|
[b554263] | 584 | </sect1>
|
---|