Page 1 of 3 123 LastLast
Results 1 to 10 of 22

Thread: .profile .bash_profile

  1. #1
    Join Date
    Aug 2009
    Location
    Pittsburgh
    Beans
    33
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    .profile .bash_profile

    Hello everyone,
    checking out man pages for bash i figured out that bash is supposed to search for .bash_profile and if it doesn't find it .bash_login and in the the end .profile.

    Ubuntu doesn't come with a .bash_profile file so I did mv .profile .bash_profile.
    The problem is that it seems like bash it's not reading .bash_profile.

    Any ideas why?
    what is ( if there is) the difference between .profile and .bash_profile?

    thanks a lot

  2. #2
    Join Date
    Jun 2009
    Location
    Alabama
    Beans
    2,232

    Re: .profile .bash_profile

    My understanding is that it always reads .profile, first. Then, if .bash_profile exists, it runs that, second.

    Tim

  3. #3
    wojox is offline I Ubuntu, Therefore, I Am
    Join Date
    Apr 2009
    Beans
    8,630

    Re: .profile .bash_profile

    .profile checks for .bash_profile and .bash_login.
    If they don't exist it hands controls over to .bashrc

  4. #4
    Join Date
    Aug 2009
    Location
    Pittsburgh
    Beans
    33
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Re: .profile .bash_profile

    this is my .profile. It seems like .profile shouldn't be read either if f ~/.bash_profile or ~/.bash_login exists.

    Code:
    # ~/.profile: executed by the command interpreter for login shells.
    # This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
    # exists.
    # see /usr/share/doc/bash/examples/startup-files for examples.
    # the files are located in the bash-doc package.
    
    # the default umask is set in /etc/profile; for setting the umask
    # for ssh logins, install and configure the libpam-umask package.
    #umask 022
    
    # if running bash
    if [ -n "$BASH_VERSION" ]; then
        # include .bashrc if it exists
        if [ -f "$HOME/.bashrc" ]; then
        . "$HOME/.bashrc"
        fi
    fi
    
    # set PATH so it includes user's private bin if it exists
    if [ -d "$HOME/bin" ] ; then
        PATH="$HOME/bin:$PATH"
    fi
    So what i am doing is creating a .bash_profile file like this:

    Code:
    REPOSITORY=somedir
    . ~/.bashrc
    and when I echo $REPOSITORY i see a blank line... I know what i am doind make not much sense since i could just plase the $REP var either in .bashrc or .profile, but I am new to ubuntu and i would like understand how it works ...

  5. #5
    Join Date
    Dec 2008
    Beans
    225

    Re: .profile .bash_profile

    Quote Originally Posted by memecs View Post
    this is my .profile. It seems like .profile shouldn't be read either if f ~/.bash_profile or ~/.bash_login exists.

    Code:
    # ~/.profile: executed by the command interpreter for login shells.
    # This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
    # exists.
    # see /usr/share/doc/bash/examples/startup-files for examples.
    # the files are located in the bash-doc package.
    
    # the default umask is set in /etc/profile; for setting the umask
    # for ssh logins, install and configure the libpam-umask package.
    #umask 022
    
    # if running bash
    if [ -n "$BASH_VERSION" ]; then
        # include .bashrc if it exists
        if [ -f "$HOME/.bashrc" ]; then
        . "$HOME/.bashrc"
        fi
    fi
    
    # set PATH so it includes user's private bin if it exists
    if [ -d "$HOME/bin" ] ; then
        PATH="$HOME/bin:$PATH"
    fi
    So what i am doing is creating a .bash_profile file like this:

    Code:
    REPOSITORY=somedir
    . ~/.bashrc
    and when I echo $REPOSITORY i see a blank line... I know what i am doind make not much sense since i could just plase the $REP var either in .bashrc or .profile, but I am new to ubuntu and i would like understand how it works ...
    you forgot to export it

    export REPOSITORY=somedir

    that should replace Repository=somedir, i got this from the LFS book i had handy.
    Last edited by mrbiggbrain; August 16th, 2009 at 05:46 AM.
    "I got this car home and all there where where a bunch of bricks?" -linux is not windows

  6. #6
    Join Date
    Aug 2009
    Location
    Pittsburgh
    Beans
    33
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Smile Re: .profile .bash_profile

    ops... i just checked in the actual script and i made export=... in it but still no way to make it worrks...

    But the directory of .bash_profile is suppsed to be ~/ right?

  7. #7
    Join Date
    Dec 2008
    Beans
    225

    Re: .profile .bash_profile

    Quote Originally Posted by memecs View Post
    ops... i just checked in the actual script and i made export=... in it but still no way to make it worrks...

    But the directory of .bash_profile is suppsed to be ~/ right?
    and you are aware that ~/.bash_profile is alogin script and is only run when you login, have you tryed running

    Code:
    source ~/.bash_profile
    and are you sure you do not need a non-login shell? ~/.bashrc might work


    for refrence

    LFS initial ~/.bash_profile
    Code:
    exec env -i HOME=${HOME} TERM=${TERM} PS1='\u:\w\$ ' /bin/bash
    LFS initial ~/.bashrc

    Code:
    set +h
    umask 022
    LFS=/mnt/clfs
    LC_ALL=POSIX
    PATH=/tools/bin:/bin:/usr/bin
    export LFS LC_ALL PATH
    "I got this car home and all there where where a bunch of bricks?" -linux is not windows

  8. #8
    Join Date
    Aug 2009
    Location
    Pittsburgh
    Beans
    33
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Re: .profile .bash_profile

    I tryed running source ~/.bash_profile and now when i echo $REPOSITORY i see the value... I could use .bashrc instead but i just want to figure out why when i login it calls .profile and doesn't call .bash_profile... it just doesn't make sense...

    thanks for helping by the way...

  9. #9
    Join Date
    Dec 2008
    Beans
    225

    Re: .profile .bash_profile

    it should read ~/.bash_profile and if that dosnt exist then read ~/.bash_login and if that dosnt exist read ~/.profile

    but as you said you belive it is reading ~/.profile first?
    "I got this car home and all there where where a bunch of bricks?" -linux is not windows

  10. #10
    Join Date
    Aug 2009
    Location
    Pittsburgh
    Beans
    33
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Re: .profile .bash_profile

    i tried to login only with .bash_profile, without .profile, and also in this case it doesn't read it. so i suppose it's not reading it at all...

Page 1 of 3 123 LastLast

Bookmarks

Posting Permissions

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