source: postlfs/config/profile.xml@ 766bbe40

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 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 766bbe40 was 766bbe40, checked in by Larry Lawrence <larry@…>, 21 years ago

tagged some writeups

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

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