source: postlfs/config/profile.xml@ 036393e1

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

more corner sweeping

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

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