LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 04-21-2005, 04:02 PM   #1
maybbach
Member
 
Registered: Feb 2004
Location: Cincinnati, OH
Distribution: SimplyMepis 3.3
Posts: 68

Rep: Reputation: 15
/etc/profile vs /etc/bashrc


can anyone tell me the difference between /etc/profile and /etc/bashrc ? from what i understand they both set system wide confgurations, so i cant understand the why both of them are there.

on another note, i feel like im being called to the other side. the more im learning about linux the more it intrigues me. i think the simplicity of windows is starting to get to me. ive installed mepis (which i love btw), and its given me the best of both worlds. im kinda starting to see *nix nerds like it so much. if anyone has any newb friendly links please let me know.

anyways thanks in advance.
 
Old 04-21-2005, 06:02 PM   #2
Ateo
Member
 
Registered: Sep 2004
Location: http://longbeach.ca.u$
Distribution: Ubuntu,Gentoo, OSX
Posts: 136

Rep: Reputation: 15
Re: /etc/profile vs /etc/bashrc

Quote:
Originally posted by maybbach
can anyone tell me the difference between /etc/profile and /etc/bashrc ? from what i understand they both set system wide confgurations, so i cant understand the why both of them are there.
Hmm. I don't think /etc/bashrc exists. I do believe you might be confusing that with your user profile, ~/.bashrc. /etc/profile sets system wide parameters for all users while ~/.bashrc just for the user.

Granted, I may be wrong since we run different distros.
 
Old 04-21-2005, 06:02 PM   #3
ultramancool
Member
 
Registered: Jul 2004
Location: Hell
Distribution: Gentoo 2005.1 r1
Posts: 92

Rep: Reputation: 15
Re: /etc/profile vs /etc/bashrc

Quote:
Originally posted by maybbach
can anyone tell me the difference between /etc/profile and /etc/bashrc ? from what i understand they both set system wide confgurations, so i cant understand the why both of them are there.

on another note, i feel like im being called to the other side. the more im learning about linux the more it intrigues me. i think the simplicity of windows is starting to get to me. ive installed mepis (which i love btw), and its given me the best of both worlds. im kinda starting to see *nix nerds like it so much. if anyone has any newb friendly links please let me know.

anyways thanks in advance.
There is no such thing as /etc/bashrc
I'm using debian sarge and don't see it. Maybe it's for some older proggy?
Don't return to M$ Toy with different distro's. I've tried SuSE, Slackware, Debian, Mandrake, Fedora and i've only been using linux for less than a year. In the end you'll find the distro u like best.
 
Old 04-21-2005, 06:13 PM   #4
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
The /etc/bashrc file is a common practice, but not directly supported by bash.

Typically, a user's ~/.bashrc will check to see if /etc/bashrc exists, and then sources it if it does. Like /etc/profile, it's intended to provide some basic, global settings for a user to start with. However, the user can completely disregard it if (s)he so desires.

The difference between them that maybbach was getting at is a subtle difference in how a shell is started. Depending on the arguments a shell receives when started, it will load /etc/profile, ~/.bash_profile, and ~/.bashrc. Other times, it only loads ~/.bashrc. To get all the gory details on what modes cause which files to be read, open up the bash man page, and scroll down to the "INVOCATION" section.

Last edited by Dark_Helmet; 04-21-2005 at 06:15 PM.
 
Old 04-21-2005, 07:36 PM   #5
mcd
Member
 
Registered: Aug 2003
Location: Boulder, CO
Distribution: Slackware, RHEL, CentOS
Posts: 825

Rep: Reputation: 33
as i understand it, .bashrc (whether the user's copy or the system-wide one) is used for login shells, and the profile is used for non-login shells. so using su will load settings from profile, and su - will load them from bashrc. i think.
 
Old 04-22-2005, 12:23 AM   #6
foo_bar_foo
Senior Member
 
Registered: Jun 2004
Posts: 2,553

Rep: Reputation: 51
Quote:
Originally posted by mcd
as i understand it, .bashrc (whether the user's copy or the system-wide one) is used for login shells, and the profile is used for non-login shells. so using su will load settings from profile, and su - will load them from bashrc. i think.
mdc has spoken the best but just has it backwards
profile is interactive login
bashrc is interactive non-login

the lines get all blurred if for instance in you ~/.bash_profile you put
if [ -f "$HOME/.bashrc" ] ; then
source $HOME/.bashrc
fi

and/or the other way around

i think /etc/bashrc is kind of important if for no other reason than to provide a different prompt for non-logins -- i use ~/.bashrc to load root only aliases for su with
if [ `whoami` = "root" ]; then
and in that instance ~/.bash_profile handles the prompt the same way

the party line is aliases and functions go in bashrc
environment variables go in profile
but rules are made to be broken
basically you just make these files do whatever you want them to do

there is another one too ~/.bash_logout to do junk on logout
 
Old 04-22-2005, 10:50 AM   #7
maybbach
Member
 
Registered: Feb 2004
Location: Cincinnati, OH
Distribution: SimplyMepis 3.3
Posts: 68

Original Poster
Rep: Reputation: 15
Re: Re: /etc/profile vs /etc/bashrc

Quote:
Originally posted by ultramancool
There is no such thing as /etc/bashrc
I'm using debian sarge and don't see it. Maybe it's for some older proggy?
Don't return to M$ Toy with different distro's. I've tried SuSE, Slackware, Debian, Mandrake, Fedora and i've only been using linux for less than a year. In the end you'll find the distro u like best.
i dont think linux has enough of what i want to switch totally. theres still a lot of problems that need to be fixed b4 it can get to ms's level imo. xp set a new standard for ms products, so for me to switch, linux has to be a whole lot better. (i can feel the flames coming already).

back on topic tho, if i put whatever global settings in /etc/profile and user settings in ~/.bashrc, i should be ok right. i can just leave /etc/bashrc and ~/.bash_profile alone and the changes should work....right?

thanks for all the explanations, it really cleared things up.

Last edited by maybbach; 04-22-2005 at 10:57 AM.
 
  


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
/etc/profile V.S. /etc/bashrc Takayuki Linux - General 12 05-18-2011 12:25 AM
/etc/profile vs. /etc/bash.bashrc jbrashear Debian 3 03-11-2004 04:49 PM
RH9 bashrc and profile magnusprime Red Hat 5 09-01-2003 06:32 PM
Where's my .bashrc or .profile t1mc00per Linux - Software 6 03-03-2003 11:35 AM
.bashrc,profile.local Cichlid Linux - Distributions 1 01-08-2002 06:22 AM


All times are GMT -5. The time now is 03:59 AM.

Main Menu
Advertisement
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