Section 6.2. Startup


[Page 204 (continued)]

6.2. Startup

Bash, like other shells, is a program. When a new Bash shell starts, it executes commands in the file ".bashrc" in the home directory of the user running Bash. The one exception is when Bash is started as a login shell, in which case it runs the commands in the file ".bash_profile" in the user's home directory instead. So if you want your ".bashrc" file to be executed in your login shell as well, you have to add this to your ".bash_profile" file:

if [ -f ~/.bashrc ]; then    . ~/.bashrc fi 



[Page 205]

We'll see how and why that works later in the chapter. This is often found by default in ".bash_profile" files on a system.

In addition to these two files, the system administrator can put initialization commands appropriate for all users in the file "/etc/profile" which Bash will also read and execute. Note that Bash will read the "/etc/profile" file first, before running any initialization files belonging to the user.




Linux for Programmers and Users
Linux for Programmers and Users
ISBN: 0131857487
EAN: 2147483647
Year: 2007
Pages: 339

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net