Find the answer to your Linux question:
Results 1 to 5 of 5
I am using the bash shell right now in RH 8.0, and I am a real newbie at all this. I am trying to understand which files control the general ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Mar 2003
    Posts
    57

    difference between .bashrc and .bash_profile


    I am using the bash shell right now in RH 8.0, and I am a real newbie at all this. I am trying to understand which files control the general environment variables. I thought it was .bashrc, but now I found another file .bash_profile that also does some Path initialization, and I was wondernig if somebody can tell me which one does what, and why there are apparently two different .profile type files. Obviously they both have their separate responsibilities, I just don't know what they are.

    I am trying to setup my environment for using the J2EE SDK, which is why I need to know this. Thanks for the information guys.

  2. #2
    Linux Enthusiast
    Join Date
    Jun 2002
    Location
    San Antonio
    Posts
    621
    to be honest, this is something I was never completely clear on either. I think .bashrc is for whenever you start bash. .bash_profile is for whenever you start bash as a login shell. I think. google around for it, I am sure someone knows which is which.
    I respectfully decline the invitation to join your delusion.

  3. #3
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    Yes, that's basically true. .bashrc is only used when you start bash as a non-login shell. There are some other files and environment variables used, too.
    All the details are well documented in bash(1) under the INVOCATION section, however, so just look in there.

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined!
    Join Date
    Mar 2003
    Posts
    57
    Thanks for the info. I am, and will he reading the bash manuals for more information. But since I am a real newbie, can you explain to me what you mean by starting a bash as a login shell. I don't really know where to start to find the meaning of that statment since, most explanations are ciruitously defined. Any documentation out there, with those keywords, just expects you to know what that means already. Please if you can separate those two situations for me I would appreciate it.

    I'd imagine when you say start bash, you mean starting a terminal? or is the bash shell something that started even before you turn a terminal on, like something that sits below the X-windows?

  6. #5
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    A login shell is the shell you get when you log in, and that means that it sets up some extra things, like aliases, extra PATH elements and completion stuff, that you only use in interactive mode, while an ordinary shell is a shell that interprets shell scripts and such, where some aliases and completion stuff won't be needed. A login shell might also print a greeting or so, and you probably won't want that in a script interpreter.
    Note, however, that a shell can be an interactive shell without being a login shell. That commonly includes the situations where the shell is invoked "under" a login shell, such as in X. All PATH elements and stuff have already been set up when the X session script runs, and therefore the shells started in xterms need not do it again.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •