Find the answer to your Linux question:
Results 1 to 4 of 4
hi guys, i am puzzled by this. i make some changes at .bash_profile and i want to load it. Code: [aisstgDB ~]$ ./.bash_profile -bash: ./.bash_profile: Permission denied [aisstgDB ~]$ . ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Dec 2009
    Posts
    14

    why do i need to add 1 more . infront when i load bash profile ??


    hi guys,

    i am puzzled by this.
    i make some changes at .bash_profile and i want to load it.

    Code:
    [aisstgDB ~]$ ./.bash_profile
    -bash: ./.bash_profile: Permission denied
    
    [aisstgDB ~]$ . ./.bash_profile
    -- working
    ------------------

    why do i need additional . infront ?

    Regards,
    Noob

  2. #2
    Just Joined!
    Join Date
    Mar 2007
    Location
    Bogotá, Colombia
    Posts
    46
    take a look at this

    Bash Reference Manual

    According to the BASH manual '.' (a period) means that bash will "Read and execute commands from the filename argument in the current shell context."

  3. #3
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    Quote Originally Posted by LSalab View Post
    take a look at this

    Bash Reference Manual

    According to the BASH manual '.' (a period) means that bash will "Read and execute commands from the filename argument in the current shell context."
    another way that is commonly referred to is "sourcing" a file. you have to be careful with sourcing files/scripts: anything that gets set in there is inherited by your current environment (which with login scripts is exactly what you want, of course). so say have a Bash "exit" call in there, and it is sourced at login...oops.

    btw, you can source a file that is in your current working dir without using the prepending "./" (which just says to look in the current working dir for the file). so this:

    Code:
    $ . ./.bash_profile
    is the same as this (but is easier to read/type):

    Code:
    $ . .bash_profile

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined!
    Join Date
    Jun 2012
    Posts
    11
    it has sort of already been said but

    Code:
    . .bash_profile
    is the same as

    Code:
    source .bash_profile
    You are essentially running the file as a script to add things into the environment, but your bash_profile does not executable permissions and is not setup to run as a script so you cannot just try and execute it.

    Once your settings are in the .bashrc file, every time you log in, that file is sourced. Since your environment is already set when you make changes, it must be sourced again to pick up the new environment changes you are making.

    You could essentially do the same thing if you were to create an actual shell script and then just run the script instead every time you make changes. You can put a setting in the .bashrc or .bash_profile to run the script at login. Probably not as efficient as just setting up the bashrc/bash_profile.

Posting Permissions

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