Find the answer to your Linux question:
Results 1 to 6 of 6
I have read that that bash uses one of these two files, depending on the type of shell being used, to configure your shell with any user specific settings. I ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Mar 2006
    Posts
    6

    Question regarding .bash_profile/.bashrc


    I have read that that bash uses one of these two files, depending on the type of shell being used, to configure your shell with any user specific settings. I have created these two files (in my /home directory) and added the aliases that I would like to use (in .bashrc). I know that they both work as I have .bash_profile sourcing .bashrc. I added an echo to both to show me that they are running and after I manually source .bash_profile, all of my aliases in .bashrc work properly. The aliases do not work in text mode or in konsole (under KDE) until I manually source them. Is there something that I need to do to get bash to use the .bash_profile or .bashrc (depending on if I am in text or X)?

    I am sure it is something simple that I am just not doing. Any help would be appreciated.

  2. #2
    Linux Enthusiast
    Join Date
    Jun 2005
    Posts
    668
    you want "-ls" on the end of your xterm and rxvt calls

    here is mine

    Code:
    rxvt -ls -bg black -fg white -g 100x30 -cr green +sb -title "kerns terminal"
    it makes it source your profile , I use .bash_profile by the way and it works fine.

  3. #3
    Just Joined! scottro's Avatar
    Join Date
    Feb 2006
    Posts
    57
    I usually have .bash_profile source .bashrc and put everything in .bashrc.

    It can be a bit tricky. For a rather long-winded explanation, which I refuse to write again, see

    http://www.freebsdforums.org/forums/...ad.php?t=37026

    post number 14 on the thread.

    Basically, .bash_profile is sourced at first login while .bashrc is sourced, not at logon, but .bashrc will be sourced for all interactive shells, that is, shells started while already logged in.

    (Note that the tests in the linked thread probably won't work. In FreeBSD, sh and bash are two separate things, in most Linux distributions, sh is simply a link to bash. )

  4. #4
    Just Joined!
    Join Date
    Mar 2006
    Posts
    6
    Quote Originally Posted by scottro
    I usually have .bash_profile source .bashrc and put everything in .bashrc.

    It can be a bit tricky. For a rather long-winded explanation, which I refuse to write again, see

    http://www.freebsdforums.org/forums/...ad.php?t=37026

    post number 14 on the thread.

    Basically, .bash_profile is sourced at first login while .bashrc is sourced, not at logon, but .bashrc will be sourced for all interactive shells, that is, shells started while already logged in.

    (Note that the tests in the linked thread probably won't work. In FreeBSD, sh and bash are two separate things, in most Linux distributions, sh is simply a link to bash. )
    Thanks. That post pointed me in the right direction. I was on the right track before in my thinking, but i just was not quite sure what I was looking for. It turns out, for some reason my etc/passwd entry did not actually list a default shell, even though it used bash by default. Adding the /bin/bash worked. Thanks for your help guys, that has been bugging me since yesterday.

  5. #5
    Linux Enthusiast
    Join Date
    Jun 2005
    Posts
    668
    I dont get why you'd have .bashrc source .bash_profile, I know about the ordering, unless you do other initialisation in .bashrc.

    I solely use .bash_profile, after all , if you're doing nothing else in .bashrc it just does nothing more than adding extra processing sourcing the .bash_profile.

    or do I have the wrong idea completely? :o

  6. #6
    Just Joined! scottro's Avatar
    Join Date
    Feb 2006
    Posts
    57
    It depends upon your situation.

    If you log in, then .bash_profile is checked. However, if you start subshells, depending on various factors, .bash_profile might not be checked, but .bashrc will be. For me, especially because I use zsh as my main shell, if I do use bash, it tends to be a subshell. So, if I only have .bash_profile, but then want to use bash instead of zsh for something, it won't be sourced. On the other hand, if I have a .bashrc, it will be sourced.

    Wow, I don't write about this very clearly, in my own opinion. Ok, right now, I'm in FreeBSD, with zsh as my shell. I have a .bash_profile that just says, source ~/.bashrc.

    If I rename .bash_profile to .bash_profile.bak and then want to use bash for something, so simply type bash at a command prompt, it will source my .bashrc.

    However, if I had no .bashrc and only had .bash_profile, and type bash at a command prompt to change shells, it won't source my .bash_profile.

    Hopefully, this is at least semi-clear

Posting Permissions

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