Results 1 to 3 of 3

Thread: .bash_profile not being executed instead of .profile

  1. #1
    Join Date
    Oct 2011
    Beans
    5

    .bash_profile not being executed instead of .profile

    My ~/.bash_profile reads,

    Code:
    export foo=one
    source ~/.profile
    And ~/.profile reads,

    Code:
    #default stuff
    export bar=two
    After logging in graphically, 'echo bar' is two but 'echo foo' is nothing. So it doesn't appear that my .bash_profile is being read. Ideas why?

    Even without the source command in ~/.bash_profile, foo still isn't set and bar is.
    Last edited by sywisy; June 12th, 2013 at 02:31 PM.

  2. #2
    Join Date
    Apr 2008
    Location
    LOCATION=/dev/random
    Beans
    5,767
    Distro
    Ubuntu Development Release

    Re: .bash_profile not being executed instead of .profile

    ~/.bash_profile is only sourced when you use a login shell (TTY or SSH usually).

    When using an interactive shell (a terminal run from a GUI) then only ~/.profile is sourced.

    Try switching to a TTY (CTRL+ALT+F1) and seeing if you get the desired result.
    Cheesemill

  3. #3
    Join Date
    Oct 2011
    Beans
    5

    Re: .bash_profile not being executed instead of .profile

    Thank you! The TTY gave me my desired result.

    I am logging into Ubuntu through the default lightdm login manager. Am I correct in saying that lightdm invokes bash through the name sh?

    From bash man page,

    Code:
    If  bash  is  invoked  with  the name sh, it tries to mimic the startup
           behavior of historical versions of sh as  closely  as  possible,  while
           conforming  to the POSIX standard as well.  When invoked as an interac‐
           tive login shell, or a non-interactive shell with the  --login  option,
           it  first  attempts  to read and execute commands from /etc/profile and
           ~/.profile, in that order.

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
  •