LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices

Reply
 
LinkBack Search this Thread
Old 02-26-2013, 12:31 PM   #1
carlosinfl
Senior Member
 
Registered: May 2004
Location: Orlando, FL
Distribution: Debian
Posts: 2,895

Rep: Reputation: 73
Question Setting ENV Variables


I've used a few distributions and I've never grasped the difference in BASH between .bashrc & .bash_profile. I find myself confused on RHEL based distributions as to which should be edited if I need to set a specific variable for that user. Is there a difference between the two and which would you set a common user env. variable?
 
Old 02-26-2013, 02:26 PM   #2
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,563

Rep: Reputation: 410Reputation: 410Reputation: 410Reputation: 410Reputation: 410
You can set them in either. There are reasons why one is used over the other but if you look at the actual bash_profile file it sources bashrc:

Code:
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi
It really doesnt matter which one you put it in, the only thing to worry about is that if there is an /etc/bashrc it will override your .bashrc settings.

---------- Post added 02-26-13 at 01:27 PM ----------

People usually recommend using .bash_profile
 
Old 02-26-2013, 07:57 PM   #3
carlosinfl
Senior Member
 
Registered: May 2004
Location: Orlando, FL
Distribution: Debian
Posts: 2,895

Original Poster
Rep: Reputation: 73
Quote:
Originally Posted by Kustom42 View Post
[/COLOR]People usually recommend using .bash_profile
Thank you very much!
 
Old 02-26-2013, 09:16 PM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 26,534
Blog Entries: 51

Rep: Reputation: 2603Reputation: 2603Reputation: 2603Reputation: 2603Reputation: 2603Reputation: 2603Reputation: 2603Reputation: 2603Reputation: 2603Reputation: 2603Reputation: 2603
Quote:
Originally Posted by carlosinfl View Post
I've used a few distributions and I've never grasped the difference in BASH between .bashrc & .bash_profile.
'man bash' is quite specific about what gets read when and in which order:
Code:
 
Bash invoked as "/bin/bash"
I. interactive login shell:
/etc/profile
  + /etc/inputrc
  + /etc/profile.d/*.sh
~/.bash_profile
  + ~/.bashrc
        + /etc/bashrc
  + ~/.bash_login
  + ~/.inputrc
~/.bash_login

II. interactive non-login shell or non-interactive:
~/.bashrc
  + /etc/bashrc
  + /etc/profile.d/*.sh
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
setting env variables. mannclay Programming 11 03-27-2009 08:14 PM
.tcshrc error and setting env. variables leblebi Linux - Newbie 1 04-14-2008 02:02 AM
setting env. variables arunsri Slackware 3 03-26-2005 05:49 AM
Setting perm env. variables for a super user. Tarts Slackware 7 08-02-2003 09:21 PM
setting env variables globally raven Linux - General 6 02-21-2003 08:04 AM


All times are GMT -5. The time now is 01:26 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
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration