Unix questions - Difference between .bashrc and .bash_profile?

This is Interesting: Free IT Magazines  
Home > Archive > Unix questions > January 2005 > Difference between .bashrc and .bash_profile?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Difference between .bashrc and .bash_profile?
Viet Nguyen

2005-01-28, 5:54 pm

What's the difference between the two bash start files ?

Viet

notbob

2005-01-28, 5:54 pm

On 2005-01-28, Viet Nguyen <downup@turtle.com> wrote:
> What's the difference between the two bash start files ?


man bash

/INVOCATION



nb
Peter T. Breuer

2005-01-28, 5:54 pm

In comp.os.linux.misc Viet Nguyen <downup@turtle.com> wrote:
> What's the difference between the two bash start files ?


There are three. No! Four. Uh, five.

I give up. What's the difference between your two hands?

Peter
Timothy Murphy

2005-01-28, 5:54 pm

Peter T. Breuer wrote:

> In comp.os.linux.misc Viet Nguyen <downup@turtle.com> wrote:
>
> There are three. No! Four. Uh, five.
>
> I give up. What's the difference between your two hands?


It was a perfectly clear and sensible question.

What is the difference in function between .bashrc and .bash_profile?
What should one put in the first, and what in the second?






--
Timothy Murphy
e-mail (<80k only): tim /at/ birdsnest.maths.tcd.ie
tel: +353-86-2336090, +353-1-2842366
s-mail: School of Mathematics, Trinity College, Dublin 2, Ireland
Floyd L. Davidson

2005-01-28, 5:54 pm

downup@turtle.com (Viet Nguyen) wrote:
>What's the difference between the two bash start files ?


(Read the man page for bash, under the section on INVOCATION,
or none of this makes half as much sense as it should.)

1) The profile file (which ever of the three files
is used) is read only by login shells.

It should have things that initialize the terminal or otherwise
need be done one time only when a user does a login. Typically,
initializing a terminal is slow. Hence one common example might
be "stty ^H erase". Another example is "PATH=~/bin:$PATH",
which is quick and easy, but if done for every subshell adds
unnecessary search elements to the PATH variable if subshells
are layers deep.

2) The rc file is read by every interactive subshell
(and not by login shells).

It should have things that are needed by for interactive use,
but are excess baggage for non-interactive subshells. Typically
that would be the definitions of aliases.

3) $ENV or $/BASH/_ENV specifies a file read by
non-interactive subshells, i.e., scripts.

This file can have functions, aliases, or variables that are
unneeded in an interactive shell.

The basic idea, which made obvious sense back when the
functionality was first added to /bash/, is to speed up shell
initialization by compartmentalizing it. When a 10Mb disk was
the norm, and it was *SLOW*, the time spent slowly reading in a
large _~/.profile_ for every single shell invocation, the way
/sh/ did, was significant and a very noticeable bottleneck.

Today of course not only is the disk file many many times faster
itself, but we have the kernel cashing oft used disk files and
it can be assumed that for a typical /bash/ invocation all of
the init files have already been cached in RAM, and no disk
activity is even done.

--
Floyd L. Davidson <http://web.newsguy.com/floyd_davidson>
Ukpeagvik (Barrow, Alaska) floyd@barrow.com
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com