source: postlfs/config/profile.xml@ 40d9d58c

10.0 10.1 11.0 11.1 11.2 11.3 12.0 12.1 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 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 v1_0 v5_0 v5_0-pre1 v5_1 v5_1-pre1 xry111/intltool xry111/llvm18 xry111/soup3 xry111/test-20220226 xry111/xf86-video-removal
Last change on this file since 40d9d58c was 7008de1, checked in by Larry Lawrence <larry@…>, 21 years ago

added sane-1.0.9, xsane-0.90, profile.xml update, fix link in sgml-dtd-3.1, updated xref in abiword

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

  • Property mode set to 100644
File size: 6.8 KB
Line 
1<sect1 id="postlfs-config-profile">
2<?dbhtml filename="profile.html" dir="postlfs"?>
3<title>The Bash Shell Startup Files</title>
4
5<para>The shell program <filename>/bin/bash</filename> (hereafter
6refered to as just "the shell") uses a collection of startup files to
7help create an environment to run in. Each file has a specific use and
8may affect login and interactive environments differently.</para>
9
10<para>An interactive login shell is started after a successful login by
11<filename>/bin/login</filename> by reading the /etc/passwd file. An
12interactive non-login shell is started at the command line (e.g.
13[prompt]$<userinput>/bin/bash</userinput>). A non-interactive shell is
14usually present when a shell script is running. It is non-interactive
15because it is processing a script and not waiting for user input between
16commands.</para>
17
18<para>For more information see <filename>info bash</filename> -- Nodes:
19Bash Startup Files and Interactive Shells</para>
20
21<para>The following files are needed to make sure that the correct
22environment is read for each of the ways the shell can be invoked:
23<filename>/etc/profile</filename>, <filename>/etc/bashrc</filename>,
24<filename>~/.bash_profile</filename>, and
25<filename>~/.bashrc</filename>. The file
26<filename>~/.bash_logout</filename> is not used for an invokation of the
27shell. It is read by the shell when a user logouts of the system. The
28files <filename>/etc/profile</filename> and
29<filename>~/.bash_profile</filename> are read when the shell is invoked
30as a interactive login shell. The file <filename>~/.bashrc</filename>
31is read when the shell is invoked as an interactive non-login
32shell.</para>
33
34<para>Here is a base <filename>/etc/profile</filename>. Comments in the
35file should explain everything you need. For more information on the
36escape sequences you can use for your prompt (e.g. the PS1 environment
37variable) see <filename>info bash</filename> -- Node: Printing a
38Prompt.</para>
39
40<para><screen># Begin /etc/profile
41# Written for Beyond Linux From Scratch
42# by James Robertson &lt;jameswrobertson@earthlink.net&gt;
43
44# System wide environment variables and startup programs.
45
46# System wide aliases and functions should go in /etc/bashrc. Personal
47# environment variables and startup programs should go into
48# ~/.bash_profile. Personal aliases and functions should go into
49# ~/.bashrc.
50
51# Function to help us manage paths
52pathman () {
53 if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then
54 if [ "$2" = "last" ] ; then
55 PATH=$PATH:$1
56 else
57 PATH=$1:$PATH
58 fi
59 fi
60}
61
62# Add to the standard path.
63if [ $(id -u) = 0 ] ; then
64 if [ -d "/usr/local/sbin" ] ; then
65 pathman /usr/local/sbin last
66 fi
67fi
68
69if [ $(id -u) != 0 ] ; then
70 if [ -d "/usr/local/bin" ] ; then
71 pathman /usr/local/bin last
72 fi
73fi
74
75if [ -d "/usr/X11R6/bin" ] ; then
76 pathman /usr/X11R6/bin last
77fi
78
79# Setup some environment variables.
80HISTSIZE=1000
81PS1="[\u@\h \w]\\$ "
82
83# Setup the INPUTRC environment variable.
84if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ] ; then
85 INPUTRC=/etc/inputrc
86fi
87
88# Setup for /bin/ls to support color, the alias is in /etc/bashrc.
89if [ -f "/etc/dircolors" ] ; then
90 eval $(dircolors -b /etc/dircolors)
91
92 if [ -f "$HOME/.dircolors" ] ; then
93 eval $(dircolors -b $HOME/.dircolors)
94 fi
95fi
96
97export PATH HISTSIZE PS1 LS_COLORS INPUTRC
98
99# End /etc/profile</screen></para>
100
101<para>Here is a base <filename>/etc/bashrc</filename>. Comments in the
102file should explain everything you need.</para>
103
104<para><screen># Begin /etc/bashrc
105# Written for Beyond Linux From Scratch
106# by James Robertson &lt;jameswrobertson@earthlink.net&gt;
107
108# System wide aliases and functions.
109
110# System wide environment variables and startup programs should go into
111# /etc/profile. Personal environment variables and startup programs
112# should go into ~/.bash_profile. Personal aliases and functions should
113# go into ~/.bashrc
114
115# By default we want the umask to get set.
116# Even for non-interactive and non-login shells.
117if [ "$(id -gn)" = "$(id -un)" -a $(id -u) -gt 99 ] ; then
118 umask 002
119else
120 umask 022
121fi
122
123# Provides a colored /bin/ls command. Used in conjunction with code in
124# /etc/profile.
125alias ls='ls --color=auto'
126
127# End /etc/bashrc</screen></para>
128
129<para>Here is a base <filename>~/.bash_profile</filename>. Comments in
130the file should explain everything you need.</para>
131
132<para><screen># Begin ~/.bash_profile
133# Written for Beyond Linux From Scratch
134# by James Robertson &lt;jameswrobertson@earthlink.net&gt;
135
136# Personal envrionment variables and startup programs.
137
138# Personal aliases and functions should go in ~/.bashrc. System wide
139# environment variables and startup programs are in /etc/profile.
140# System wide aliases and functions are in /etc/bashrc.
141
142if [ -f "$HOME/.bashrc" ] ; then
143 source $HOME/.bashrc
144fi
145
146if [ -d "$HOME/bin" ] ; then
147 pathman $HOME/bin last
148fi
149
150export PATH
151
152# End ~/.bash_profile</screen></para>
153
154<para>Here is a base <filename>~/.bashrc</filename>. Comments in the
155file should explain everything you need.</para>
156
157<para><screen># Begin ~/.bashrc
158# Written for Beyond Linux From Scratch
159# by James Robertson &lt;jameswrobertson@earthlink.net&gt;
160
161# Personal aliases and functions.
162
163# Personal environment variables and startup programs should go in
164# ~/.bash_profile. System wide environment variables and starup
165# programs are in /etc/profile. System wide aliases and functions are
166# in /etc/bashrc.
167
168if [ -f "/etc/bashrc" ] ; then
169 source /etc/bashrc
170fi
171
172# End ~/.bashrc</screen></para>
173
174<para>Here is a base <filename>~/.bash_logout</filename>. Comments in
175the file should explain everything you need. You will notice that the
176base <filename>~/.bash_logout</filename> does not include a
177<userinput>clear</userinput> command. This is because the clear is
178handled in the <filename>/etc/issue</filename> file.</para>
179
180<para><screen># Begin ~/.bash_logout
181# Written for Beyond Linux From Scratch
182# by James Robertson &lt;jameswrobertson@earthlink.net&gt;
183
184# Personal items to perform on logout.
185
186# End ~/.bash_logout</screen></para>
187
188<para>If you want to use the <filename>/etc/dircolors</filename> or
189<filename>~/.dircolors</filename> files called from
190<filename>/etc/profile</filename>, then run the following:
191<userinput>/bin/dircolors -p > /etc/dircolors</userinput> or
192<userinput>/bin/dircolors -p > ~/.dircolors</userinput> respectively.
193The file in the <filename>/etc</filename> directory should be used for
194global settings and if one exists in your home directory then it will
195overwrite the global settings. It might be a good idea to create a base
196<filename>.dircolors</filename> file and place it in the
197<filename>/etc/skel</filename> directory for new users.</para>
198
199<para>Ian Macdonald has written an excellent collection of tips and
200tricks to enhance your shell environment. You can read it online at
201<ulink
202url="http://www.caliban.org/bash/index.shtml">http://www.caliban.org/bash/index.shtml</ulink></para>
203
204</sect1>
Note: See TracBrowser for help on using the repository browser.