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 |
|
---|
8 | <sect1 id="postlfs-config-profile" xreflabel="The Bash Shell Startup Files">
|
---|
9 | <sect1info>
|
---|
10 | <othername>$LastChangedBy$</othername>
|
---|
11 | <date>$Date$</date>
|
---|
12 | </sect1info>
|
---|
13 | <?dbhtml filename="profile.html"?>
|
---|
14 | <title>The Bash Shell Startup Files</title>
|
---|
15 |
|
---|
16 | <para>The shell program <filename>/bin/bash</filename> (hereafter
|
---|
17 | referred to as just "the shell") uses a collection of startup files to
|
---|
18 | help create an environment. Each file has a specific use and
|
---|
19 | may affect login and interactive environments differently. The files in
|
---|
20 | the <filename class="directory">/etc</filename> directory generally provide global
|
---|
21 | settings. If an equivalent file exists in your home directory it may
|
---|
22 | override the global settings.
|
---|
23 | </para>
|
---|
24 |
|
---|
25 | <para>An interactive login shell is started after a successful login, using
|
---|
26 | <filename>/bin/login</filename>, by reading the <filename>/etc/passwd</filename>
|
---|
27 | file. This shell invocation normally reads <filename>/etc/profile</filename>
|
---|
28 | and its private equivalent <filename>~/.bash_profile</filename> upon startup.</para>
|
---|
29 |
|
---|
30 | <para>An interactive non-login shell is normally started at the command-line
|
---|
31 | (e.g., <prompt>[prompt]$</prompt><command>/bin/bash</command>) or by the
|
---|
32 | <command>/bin/su</command> command. An interactive non-login shell is also
|
---|
33 | started with a terminal program such as <command>xterm</command> or
|
---|
34 | <command>konsole</command> from within a graphical environment. This type of
|
---|
35 | shell invocation normally copies the parent environment and then reads the
|
---|
36 | user's <filename>~/.bashrc</filename> file for additional startup configuration
|
---|
37 | instructions.</para>
|
---|
38 |
|
---|
39 | <para>A non-interactive shell is usually present when a shell script is
|
---|
40 | running. It is non-interactive because it is processing a script and not
|
---|
41 | waiting for user input between commands. For these shell invocations, only
|
---|
42 | the environment inherited from the parent shell is used.</para>
|
---|
43 |
|
---|
44 | <para> The file <filename>~/.bash_logout</filename> is not used for an
|
---|
45 | invocation of the shell. It is read and executed when a user exits from an
|
---|
46 | interactive login shell.</para>
|
---|
47 |
|
---|
48 | <para>To the standard files, we also add <filename>/etc/bashrc</filename>
|
---|
49 | which is called from the user's <filename>~/.bashrc</filename> for
|
---|
50 | system wide initialization of non-login shells.</para>
|
---|
51 |
|
---|
52 | <para>For more information see <command>info bash</command> --
|
---|
53 | <emphasis role="strong">Nodes: Bash Startup Files and Interactive
|
---|
54 | Shells.</emphasis></para>
|
---|
55 |
|
---|
56 | <sect2>
|
---|
57 | <title><filename>/etc/profile</filename></title>
|
---|
58 |
|
---|
59 | <para>Here is a base <filename>/etc/profile</filename>. This file starts by
|
---|
60 | setting up some helper functions and some basic parameters. It specifies some
|
---|
61 | <filename>bash</filename> history parameters and, for security purposes,
|
---|
62 | disables keeping a permanent history file for the root user. It also sets a
|
---|
63 | default user prompt. It then calls small, single purpose scripts in the
|
---|
64 | <filename class='directory'>/etc/profile.d</filename> directory to provide most
|
---|
65 | initialization. </para>
|
---|
66 |
|
---|
67 | <para>For more information on the escape sequences you can use for your prompt
|
---|
68 | (e.g., the <envar>PS1</envar> environment variable) see <command>info
|
---|
69 | bash</command> -- <emphasis role="strong">Node: Printing a
|
---|
70 | Prompt.</emphasis></para>
|
---|
71 |
|
---|
72 | <screen><userinput><command>cat > /etc/profile << "EOF"</command>
|
---|
73 | # Begin /etc/profile
|
---|
74 | # Written for Beyond Linux From Scratch
|
---|
75 | # by James Robertson <jameswrobertson@earthlink.net>
|
---|
76 | # modifications by Dagmar d'Surreal <rivyqntzne@pbzpnfg.arg>
|
---|
77 |
|
---|
78 | # System wide environment variables and startup programs.
|
---|
79 |
|
---|
80 | # System wide aliases and functions should go in /etc/bashrc. Personal
|
---|
81 | # environment variables and startup programs should go into
|
---|
82 | # ~/.bash_profile. Personal aliases and functions should go into
|
---|
83 | # ~/.bashrc.
|
---|
84 |
|
---|
85 | # Functions to help us manage paths. Second argument is the name of the
|
---|
86 | # path variable to be modified (default: PATH)
|
---|
87 | pathremove () {
|
---|
88 | local IFS=':'
|
---|
89 | local NEWPATH
|
---|
90 | local DIR
|
---|
91 | local PATHVARIABLE=${2:-PATH}
|
---|
92 | for DIR in ${!PATHVARIABLE} ; do
|
---|
93 | if [ "$DIR" != "$1" ] ; then
|
---|
94 | NEWPATH=${NEWPATH:+$NEWPATH:}$DIR
|
---|
95 | fi
|
---|
96 | done
|
---|
97 | export $PATHVARIABLE="$NEWPATH"
|
---|
98 | }
|
---|
99 |
|
---|
100 | pathprepend () {
|
---|
101 | pathremove $1 $2
|
---|
102 | local PATHVARIABLE=${2:-PATH}
|
---|
103 | export $PATHVARIABLE="$1${!PATHVARIABLE:+:${!PATHVARIABLE}}"
|
---|
104 | }
|
---|
105 |
|
---|
106 | pathappend () {
|
---|
107 | pathremove $1 $2
|
---|
108 | local PATHVARIABLE=${2:-PATH}
|
---|
109 | export $PATHVARIABLE="${!PATHVARIABLE:+${!PATHVARIABLE}:}$1"
|
---|
110 | }
|
---|
111 |
|
---|
112 |
|
---|
113 | # Set the initial path
|
---|
114 | export PATH=/bin:/usr/bin
|
---|
115 |
|
---|
116 | if [ $EUID -eq 0 ] ; then
|
---|
117 | pathappend /sbin:/usr/sbin
|
---|
118 | unset HISTFILE
|
---|
119 | fi
|
---|
120 |
|
---|
121 | # Setup some environment variables.
|
---|
122 | export HISTSIZE=1000
|
---|
123 | export HISTIGNORE="&:[bf]g:exit"
|
---|
124 | #export PS1="[\u@\h \w]\\$ "
|
---|
125 | export PS1='\u@\h:\w\$ '
|
---|
126 |
|
---|
127 | for script in /etc/profile.d/*.sh ; do
|
---|
128 | if [ -r $script ] ; then
|
---|
129 | . $script
|
---|
130 | fi
|
---|
131 | done
|
---|
132 |
|
---|
133 | # Now to clean up after ourselves
|
---|
134 | unset pathremove pathprepend pathappend
|
---|
135 |
|
---|
136 | # End /etc/profile
|
---|
137 | <command>EOF</command></userinput></screen>
|
---|
138 |
|
---|
139 | <para>Now create the <filename class='directory'>/etc/profile.d</filename> directory.</para>
|
---|
140 |
|
---|
141 | <screen><userinput><command>install --directory --mode=0755 --owner=root --group=root /etc/profile.d</command></userinput></screen>
|
---|
142 |
|
---|
143 | <sect3>
|
---|
144 | <title><filename>/etc/profile.d/dircolors.sh</filename></title>
|
---|
145 |
|
---|
146 | <para>This script uses the <filename>~/.dircolors</filename> and
|
---|
147 | <filename>/etc/dircolors</filename> files to control the colors of file names in a
|
---|
148 | directory listing. They control colorized output of things like <command>ls
|
---|
149 | --color</command>. The explaination of how to initialize these files is at the
|
---|
150 | end of this section. </para>
|
---|
151 |
|
---|
152 |
|
---|
153 | <screen><userinput><command>cat > /etc/profile.d/dircolors.sh << "EOF"</command>
|
---|
154 | # Setup for /bin/ls to support color, the alias is in /etc/bashrc.
|
---|
155 | if [ -f "/etc/dircolors" ] ; then
|
---|
156 | eval $(dircolors -b /etc/dircolors)
|
---|
157 |
|
---|
158 | if [ -f "$HOME/.dircolors" ] ; then
|
---|
159 | eval $(dircolors -b $HOME/.dircolors)
|
---|
160 | fi
|
---|
161 | fi
|
---|
162 | alias ls='ls --color=auto'
|
---|
163 | <command>EOF</command></userinput></screen>
|
---|
164 | </sect3>
|
---|
165 |
|
---|
166 |
|
---|
167 | <sect3>
|
---|
168 | <title><filename>/etc/profile.d/extrapaths.sh</filename></title>
|
---|
169 |
|
---|
170 | <para>This script adds several useful paths to the <envar>PATH</envar> and
|
---|
171 | <envar>PKG_CONFIG_PATH</envar> environment variables. If you want, you can uncomment
|
---|
172 | the last section to put a dot at the end of your path. This will allow executables in the
|
---|
173 | current working directory to be executed without specifiying a ./, however
|
---|
174 | you are warned that this is generally considered a security hazard.</para>
|
---|
175 |
|
---|
176 | <screen><userinput><command>cat > /etc/profile.d/extrapaths.sh << "EOF"</command>
|
---|
177 | if [ -d /usr/local/lib/pkgconfig ] ; then
|
---|
178 | pathappend /usr/local/lib/pkgconfig PKG_CONFIG_PATH
|
---|
179 | fi
|
---|
180 | if [ -d /usr/local/bin ]; then
|
---|
181 | pathprepend /usr/local/bin
|
---|
182 | fi
|
---|
183 | if [ -d /usr/local/sbin -a $EUID -eq 0 ]; then
|
---|
184 | pathprepend /usr/local/sbin
|
---|
185 | fi
|
---|
186 | for directory in $(find /opt/*/lib/pkgconfig -type d 2>/dev/null); do
|
---|
187 | pathappend $directory PKG_CONFIG_PATH
|
---|
188 | done
|
---|
189 | for directory in $(find /opt/*/bin -type d 2>/dev/null); do
|
---|
190 | pathappend $directory
|
---|
191 | done
|
---|
192 | if [ -d ~/bin ]; then
|
---|
193 | pathprepend ~/bin
|
---|
194 | fi
|
---|
195 | #if [ $EUID -gt 99 ]; then
|
---|
196 | # pathappend .
|
---|
197 | #fi
|
---|
198 | <command>EOF</command></userinput></screen>
|
---|
199 | </sect3>
|
---|
200 |
|
---|
201 | <sect3>
|
---|
202 | <title><filename>/etc/profile.d/readline.sh</filename></title>
|
---|
203 |
|
---|
204 | <para>This script sets up the default <filename>inputrc</filename> configuration file.
|
---|
205 | If the user does not have individual settings, it uses the global file.</para>
|
---|
206 |
|
---|
207 | <screen><userinput><command>cat > /etc/profile.d/readline.sh << "EOF"</command>
|
---|
208 | # Setup the INPUTRC environment variable.
|
---|
209 | if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ] ; then
|
---|
210 | INPUTRC=/etc/inputrc
|
---|
211 | fi
|
---|
212 | export INPUTRC
|
---|
213 | <command>EOF</command></userinput></screen>
|
---|
214 | </sect3>
|
---|
215 |
|
---|
216 | <sect3>
|
---|
217 | <title><filename>/etc/profile.d/tinker-term.sh</filename></title>
|
---|
218 |
|
---|
219 | <para>Some applications need a specific <envar>TERM</envar> setting to support color.</para>
|
---|
220 |
|
---|
221 | <screen><userinput><command>cat > /etc/profile.d/tinker-term.sh << "EOF"</command>
|
---|
222 | # This will tinker with the value of TERM in order to convince certain
|
---|
223 | # apps that we can, indeed, display color in their window.
|
---|
224 |
|
---|
225 | if [ -n "$COLORTERM" ]; then
|
---|
226 | export TERM=xterm-color
|
---|
227 | fi
|
---|
228 |
|
---|
229 | if [ "$TERM" = "xterm" ]; then
|
---|
230 | export TERM=xterm-color
|
---|
231 | fi
|
---|
232 | <command>EOF</command></userinput></screen>
|
---|
233 | </sect3>
|
---|
234 |
|
---|
235 | <sect3>
|
---|
236 | <title><filename>/etc/profile.d/umask.sh</filename></title>
|
---|
237 |
|
---|
238 | <para>Setting the <command>umask</command> value is important for security. Here
|
---|
239 | we turn off the default group write permissions for system users and when the
|
---|
240 | user name and group name are not the same.</para>
|
---|
241 |
|
---|
242 | <screen><userinput><command>cat > /etc/profile.d/umask.sh << "EOF"</command>
|
---|
243 | # By default we want the umask to get set.
|
---|
244 | if [ "$(id -gn)" = "$(id -un)" -a $EUID -gt 99 ] ; then
|
---|
245 | umask 002
|
---|
246 | else
|
---|
247 | umask 022
|
---|
248 | fi
|
---|
249 | <command>EOF</command></userinput></screen>
|
---|
250 | </sect3>
|
---|
251 |
|
---|
252 | <sect3>
|
---|
253 | <title><filename>/etc/profile.d/X.sh</filename></title>
|
---|
254 |
|
---|
255 | <para>If <application>X</application> is installed, we also update the <envar>PATH</envar>
|
---|
256 | and <envar>PKG_CONFIG_PATH</envar> variables.</para>
|
---|
257 |
|
---|
258 | <screen><userinput><command>cat > /etc/profile.d/X.sh << "EOF"</command>
|
---|
259 | if [ -x /usr/X11R6/bin/X ]; then
|
---|
260 | pathappend /usr/X11R6/bin
|
---|
261 | fi
|
---|
262 | if [ -d /usr/X11R6/lib/pkgconfig ] ; then
|
---|
263 | pathappend /usr/X11R6/lib/pkgconfig PKG_CONFIG_PATH
|
---|
264 | fi
|
---|
265 | <command>EOF</command></userinput></screen>
|
---|
266 | </sect3>
|
---|
267 |
|
---|
268 | <sect3>
|
---|
269 | <title><filename>/etc/profile.d/xterm-titlebars.sh</filename></title>
|
---|
270 |
|
---|
271 | <para>This script shows an example of a different way of setting the prompt. The normal
|
---|
272 | variable, <envar>PS1</envar>, is supplemented by <envar>PROMPT_COMMAND</envar>.
|
---|
273 | If set, the value of <envar>PROMPT_COMMAND</envar> is executed as a command prior to
|
---|
274 | issuing each primary prompt. </para>
|
---|
275 |
|
---|
276 | <screen><userinput><command>cat > /etc/profile.d/xterm-titlebars.sh << "EOF"</command>
|
---|
277 | # The substring match ensures this works for "xterm" and "xterm-xfree86".
|
---|
278 | if [ "${TERM:0:5}" = "xterm" ]; then
|
---|
279 | PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME} : ${PWD}\007"'
|
---|
280 | export PROMPT_COMMAND
|
---|
281 | fi
|
---|
282 | <command>EOF</command></userinput></screen>
|
---|
283 | </sect3>
|
---|
284 |
|
---|
285 | <sect3>
|
---|
286 | <title><filename>/etc/profile.d/i18n.sh</filename></title>
|
---|
287 |
|
---|
288 | <para>This script shows how to set some environment variables necessary for
|
---|
289 | native language support. Setting these variables properly gives you:</para>
|
---|
290 |
|
---|
291 | <itemizedlist spacing="compact">
|
---|
292 | <listitem><para>the output of programs translated into your native
|
---|
293 | language</para></listitem>
|
---|
294 | <listitem><para>correct classification of characters into letters, digits and
|
---|
295 | other classes – this is necessary for <application>Bash</application> to
|
---|
296 | accept keystrokes properly in non-English locales</para></listitem>
|
---|
297 | <listitem><para>the alphabetical sorting order correct for your
|
---|
298 | country</para></listitem>
|
---|
299 | <listitem><para>proper default paper size</para></listitem>
|
---|
300 | <listitem><para>correct formatting of monetary, time and date
|
---|
301 | values</para></listitem>
|
---|
302 | </itemizedlist>
|
---|
303 |
|
---|
304 | <para>Replace <replaceable>[ll]</replaceable> with the two-letter code for
|
---|
305 | your language (e.g., <quote>en</quote>) and
|
---|
306 | <replaceable>[CC]</replaceable> with the two-letter code for your country
|
---|
307 | (e.g., <quote>GB</quote>). Also you may need to specify (and this is actually
|
---|
308 | the preferred form) your character encoding (e.g., <quote>iso8859-1</quote>)
|
---|
309 | after a dot (so that the result is <quote>en_GB.iso8859-1</quote>). Issue the
|
---|
310 | following command for more information:</para>
|
---|
311 |
|
---|
312 | <screen><userinput><command>man 3 setlocale</command></userinput></screen>
|
---|
313 |
|
---|
314 | <para>The list of all locales supported by <application>Glibc</application>
|
---|
315 | can be obtained by running the following command:</para>
|
---|
316 |
|
---|
317 | <screen><userinput><command>locale -a</command></userinput></screen>
|
---|
318 |
|
---|
319 | <para>After you are sure about your locale settings, create the
|
---|
320 | <filename>/etc/profile.d/i18n.sh</filename> file:</para>
|
---|
321 |
|
---|
322 | <screen><userinput><command>cat > /etc/profile.d/i18n.sh << "EOF"</command>
|
---|
323 | # Set up i18n variables
|
---|
324 | export LC_ALL=<replaceable>[ll]</replaceable>_<replaceable>[CC]</replaceable>
|
---|
325 | export LANG=<replaceable>[ll]</replaceable>_<replaceable>[CC]</replaceable>
|
---|
326 | export G_FILENAME_ENCODING=@locale
|
---|
327 | <command>EOF</command></userinput></screen>
|
---|
328 |
|
---|
329 | <para>The <envar>LC_ALL</envar> variable sets the same value for all locale categories. For
|
---|
330 | better control, you may prefer to set values individually for all categories
|
---|
331 | listed in the output of the <command>locale</command> command.</para>
|
---|
332 |
|
---|
333 | <para>The <envar>G_FILENAME_ENCODING</envar> variable tells applications
|
---|
334 | such as <application>Glib</application> and
|
---|
335 | <application><acronym>GTK</acronym>+</application> that filenames are in
|
---|
336 | the default locale encoding and not in <acronym>UTF</acronym>-8 as
|
---|
337 | assumed by default.</para>
|
---|
338 | </sect3>
|
---|
339 |
|
---|
340 | <sect3>
|
---|
341 | <title><filename>Other initialization values</filename></title>
|
---|
342 |
|
---|
343 | <para>Other initialization can easily be added to the <filename>profile</filename>
|
---|
344 | by adding additional scripts to the
|
---|
345 | <filename class='directory'>/etc/profile.d</filename> directory.</para>
|
---|
346 | </sect3>
|
---|
347 |
|
---|
348 | </sect2>
|
---|
349 |
|
---|
350 | <sect2>
|
---|
351 | <title><filename>/etc/bashrc</filename></title>
|
---|
352 | <para>Here is a base <filename>/etc/bashrc</filename>. Comments in the
|
---|
353 | file should explain everything you need.</para>
|
---|
354 |
|
---|
355 | <screen><userinput><command>cat > /etc/bashrc << "EOF"</command>
|
---|
356 | # Begin /etc/bashrc
|
---|
357 | # Written for Beyond Linux From Scratch
|
---|
358 | # by James Robertson <jameswrobertson@earthlink.net>
|
---|
359 | # updated by Bruce Dubbs <bdubbs@linuxfromscratch.org>
|
---|
360 |
|
---|
361 | # Make sure that the terminal is set up properly for each shell
|
---|
362 |
|
---|
363 | if [ -f /etc/profile.d/tinker-term.sh ]; then
|
---|
364 | source /etc/profile.d/tinker-term.sh
|
---|
365 | fi
|
---|
366 |
|
---|
367 | if [ -f /etc/profile.d/xterm-titlebars.sh ]; then
|
---|
368 | source /etc/profile.d/xterm-titlebars.sh
|
---|
369 | fi
|
---|
370 |
|
---|
371 | # System wide aliases and functions.
|
---|
372 |
|
---|
373 | # System wide environment variables and startup programs should go into
|
---|
374 | # /etc/profile. Personal environment variables and startup programs
|
---|
375 | # should go into ~/.bash_profile. Personal aliases and functions should
|
---|
376 | # go into ~/.bashrc
|
---|
377 |
|
---|
378 | # Provides a colored /bin/ls command. Used in conjunction with code in
|
---|
379 | # /etc/profile.
|
---|
380 |
|
---|
381 | alias ls='ls --color=auto'
|
---|
382 |
|
---|
383 | # Provides prompt for non-login shells, specifically shells started
|
---|
384 | # in the <application>X</application> environment. [Review the LFS archive thread titled
|
---|
385 | # PS1 Environment Variable for a great case study behind this script
|
---|
386 | # addendum.]
|
---|
387 |
|
---|
388 | #export PS1="[\u@\h \w]\\$ "
|
---|
389 | export PS1='\u@\h:\w\$ '
|
---|
390 |
|
---|
391 | # End /etc/bashrc
|
---|
392 | <command>EOF</command></userinput></screen>
|
---|
393 | </sect2>
|
---|
394 |
|
---|
395 |
|
---|
396 | <sect2>
|
---|
397 | <title><filename>~/.bash_profile</filename></title>
|
---|
398 |
|
---|
399 | <para>Here is a base <filename>~/.bash_profile</filename>. If you want each
|
---|
400 | new user to have this file automatically, just change the output of
|
---|
401 | the command to <filename>/etc/skel/.bash_profile</filename> and check the
|
---|
402 | permissions after the command is run. You can then copy
|
---|
403 | <filename>/etc/skel/.bash_profile</filename> to the home directories of already
|
---|
404 | existing users, including root, and set the owner and group appropriately.
|
---|
405 | </para>
|
---|
406 |
|
---|
407 | <screen><userinput><command>cat > ~/.bash_profile << "EOF"</command>
|
---|
408 | # Begin ~/.bash_profile
|
---|
409 | # Written for Beyond Linux From Scratch
|
---|
410 | # by James Robertson <jameswrobertson@earthlink.net>
|
---|
411 | # updated by Bruce Dubbs <bdubbs@linuxfromscratch.org>
|
---|
412 |
|
---|
413 | # Personal environment variables and startup programs.
|
---|
414 |
|
---|
415 | # Personal aliases and functions should go in ~/.bashrc. System wide
|
---|
416 | # environment variables and startup programs are in /etc/profile.
|
---|
417 | # System wide aliases and functions are in /etc/bashrc.
|
---|
418 |
|
---|
419 | append () {
|
---|
420 | # First remove the directory
|
---|
421 | local IFS=':'
|
---|
422 | local NEWPATH
|
---|
423 | for DIR in $PATH; do
|
---|
424 | if [ "$DIR" != "$1" ]; then
|
---|
425 | NEWPATH=${NEWPATH:+$NEWPATH:}$DIR
|
---|
426 | fi
|
---|
427 | done
|
---|
428 |
|
---|
429 | # Then append the directory
|
---|
430 | export PATH=$NEWPATH:$1
|
---|
431 | }
|
---|
432 |
|
---|
433 | if [ -f "$HOME/.bashrc" ] ; then
|
---|
434 | source $HOME/.bashrc
|
---|
435 | fi
|
---|
436 |
|
---|
437 | if [ -d "$HOME/bin" ] ; then
|
---|
438 | append $HOME/bin
|
---|
439 | fi
|
---|
440 |
|
---|
441 | unset append
|
---|
442 |
|
---|
443 | # End ~/.bash_profile
|
---|
444 | <command>EOF</command></userinput></screen>
|
---|
445 | </sect2>
|
---|
446 |
|
---|
447 | <sect2>
|
---|
448 | <title><filename>~/.bashrc</filename></title>
|
---|
449 |
|
---|
450 | <para>Here is a base <filename>~/.bashrc</filename>. The comments and
|
---|
451 | instructions for using <filename class="directory">/etc/skel</filename> for
|
---|
452 | <filename>.bash_profile</filename> above also apply here. Only the target file
|
---|
453 | names are different.</para>
|
---|
454 |
|
---|
455 | <screen><userinput><command>cat > ~/.bashrc << "EOF"</command>
|
---|
456 | # Begin ~/.bashrc
|
---|
457 | # Written for Beyond Linux From Scratch
|
---|
458 | # by James Robertson <jameswrobertson@earthlink.net>
|
---|
459 |
|
---|
460 | # Personal aliases and functions.
|
---|
461 |
|
---|
462 | # Personal environment variables and startup programs should go in
|
---|
463 | # ~/.bash_profile. System wide environment variables and startup
|
---|
464 | # programs are in /etc/profile. System wide aliases and functions are
|
---|
465 | # in /etc/bashrc.
|
---|
466 |
|
---|
467 | if [ -f "/etc/bashrc" ] ; then
|
---|
468 | source /etc/bashrc
|
---|
469 | fi
|
---|
470 |
|
---|
471 | # End ~/.bashrc
|
---|
472 | <command>EOF</command></userinput></screen>
|
---|
473 | </sect2>
|
---|
474 |
|
---|
475 |
|
---|
476 | <sect2>
|
---|
477 | <title><filename>~/.bash_logout</filename></title>
|
---|
478 |
|
---|
479 | <para>This is an empty <filename>~/.bash_logout</filename> that can be used as
|
---|
480 | a template. You will notice that the base <filename>~/.bash_logout</filename>
|
---|
481 | does not include a <userinput>clear</userinput> command. This is because the
|
---|
482 | clear is handled in the <filename>/etc/issue</filename> file.</para>
|
---|
483 |
|
---|
484 | <screen><userinput><command>cat > ~/.bash_logout << "EOF"</command>
|
---|
485 | # Begin ~/.bash_logout
|
---|
486 | # Written for Beyond Linux From Scratch
|
---|
487 | # by James Robertson <jameswrobertson@earthlink.net>
|
---|
488 |
|
---|
489 | # Personal items to perform on logout.
|
---|
490 |
|
---|
491 | # End ~/.bash_logout
|
---|
492 | <command>EOF</command></userinput></screen>
|
---|
493 | </sect2>
|
---|
494 |
|
---|
495 |
|
---|
496 | <sect2>
|
---|
497 | <title><filename>/etc/dircolors</filename></title>
|
---|
498 |
|
---|
499 | <para> If you want to use the <filename>dircolors</filename> capability, then
|
---|
500 | run the following command. The <filename class="directory">/etc/skel</filename>
|
---|
501 | setup steps seen above also can be used here to provide a
|
---|
502 | <filename>.dircolors</filename> file when a new user is set up. As before, just
|
---|
503 | change the output file name on the following command and assure the
|
---|
504 | permissions, owner, and group are correct on the files created and/or copied.
|
---|
505 | </para>
|
---|
506 |
|
---|
507 | <screen><userinput><command>dircolors -p > /etc/dircolors</command></userinput></screen>
|
---|
508 |
|
---|
509 | <para>If you wish to customize the colors used for different file types, you can
|
---|
510 | edit the <filename>/etc/dircolors</filename> file. The instructions for setting
|
---|
511 | the colors are embedded in the file.</para>
|
---|
512 |
|
---|
513 |
|
---|
514 | <para>Finally, Ian Macdonald has written an excellent collection of tips and
|
---|
515 | tricks to enhance your shell environment. You can read it online at
|
---|
516 | <ulink
|
---|
517 | url="http://www.caliban.org/bash/index.shtml">http://www.caliban.org/bash/index.shtml</ulink>.</para>
|
---|
518 | </sect2>
|
---|
519 | </sect1>
|
---|