LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux > Linux - General
User Name
Password
Linux - General This forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Thread Tools
Old 08-30-2003, 04:48 PM   #1
mikeshn
Member
 
Registered: Feb 2002
Distribution: Fedora Core 2
Posts: 587
Thanked: 0
bashrc vs. bash_profile


[Log in to get rid of this advertisement]
These two files looks pretty similar. What is the purpose of these files ?

Thanks
mikeshn is offline     Reply With Quote
Old 08-30-2003, 05:01 PM   #2
DrOzz
Senior Member
 
Registered: May 2003
Location: Sydney, Nova Scotia, Canada
Distribution: slackware
Posts: 4,184
Thanked: 0
things like:
PATHS
custom PS1 strings
aliases
....etc,are stored in these files...
DrOzz is offline     Reply With Quote
Old 08-30-2003, 05:08 PM   #3
Skyline
Senior Member
 
Registered: Jun 2003
Distribution: Debian/other
Posts: 2,103
Thanked: 0
One important distinction is that bash_profile is read when you loggin whereas bashrc is read each time you open a bash shell after youve logged in.
Skyline is offline     Reply With Quote
Old 08-30-2003, 05:11 PM   #4
SaTaN
Member
 
Registered: Aug 2003
Location: Suprisingly in Heaven
Posts: 223
Thanked: 1
When you start a login shell, bash consults the following files in the specified order:
1. /etc/profile
2. ~/.bash.profile
3. ~/.bash_login
4. ~/.profile
When you start a nonlogin shell, bash consults only one startup file, ~/bash.rc.
SaTaN is offline     Reply With Quote
Old 09-24-2003, 08:45 AM   #5
mikeshn
Member
 
Registered: Feb 2002
Distribution: Fedora Core 2
Posts: 587
Thanked: 0

Original Poster
Quote:
Originally posted by SaTaN
When you start a login shell, bash consults the following files in the specified order:
1. /etc/profile
2. ~/.bash.profile
3. ~/.bash_login
4. ~/.profile
When you start a nonlogin shell, bash consults only one startup file, ~/bash.rc.
What do you mean by "nonlogin shell"? When OS starts?
mikeshn is offline     Reply With Quote
Old 09-24-2003, 05:43 PM   #6
Skyline
Senior Member
 
Registered: Jun 2003
Distribution: Debian/other
Posts: 2,103
Thanked: 0
Just think of a non-login shell as when you open a new instance of bash up after youve logged in - each time you do this the ~/.bashrc file is read - this file is good for putting Aliases in amongst other things.
Skyline is offline     Reply With Quote
Old 09-27-2003, 08:27 PM   #7
bleedingpegasus
LQ Newbie
 
Registered: Sep 2003
Location: where rainbow begins
Distribution: RH Psyche
Posts: 7
Thanked: 0
is there any command that can be use for restarting the .bash_profile, so don;t have to restart the whole pc?
i mean, like in windows, you can restart the 'explorer' only if you made changes in registry....

TIA.
bleedingpegasus is offline     Reply With Quote
Old 09-28-2003, 12:43 AM   #8
SaTaN
Member
 
Registered: Aug 2003
Location: Suprisingly in Heaven
Posts: 223
Thanked: 1
On the command line:-
. .bash_profile
SaTaN is offline     Reply With Quote
Old 10-04-2003, 09:20 PM   #9
mikeshn
Member
 
Registered: Feb 2002
Distribution: Fedora Core 2
Posts: 587
Thanked: 0

Original Poster
What .(dot) before .bash_profile does?
mikeshn is offline     Reply With Quote
Old 02-10-2008, 02:46 PM   #10
vamped
LQ Newbie
 
Registered: Oct 2006
Posts: 8
Thanked: 0
Quote:
Originally Posted by mikeshn View Post
What .(dot) before .bash_profile does?
It's been a long time, but for completeness:

If you run it like:
$ .bash_profile
it creates a new process to run the file. Any aliases created will be valid only for that process. When the file is finished running, that process ends, and the new aliases expire.
If you run it like:
$ . .bash_profile
it runs it in the current process. When the file is finished executing, the new aliases are still valid.

See $man . OR $man source
vamped is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
bashrc or bash_profile ? ARCIS_house Linux - Newbie 6 07-21-2005 03:09 PM
.bashrc .bash_profile Soulful93 Slackware 4 05-03-2005 04:02 AM
~/.bashrc, ~/.bash_profile Sinope Linux - Newbie 6 08-17-2004 03:40 AM
.bashrc or .bash_profile? statmobile Linux - Newbie 1 02-04-2004 10:08 PM
.bashrc vs .bash_profile xor3 Linux - Newbie 1 08-16-2003 01:52 PM


All times are GMT -5. The time now is 01:05 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration