1

I need to add a new directory to my PATH so that SublimeText can find it. I assume this should be added to either .bash_profile, .bashrc, or .profile.

Which one should I add it to?

.bash_profile already has:

export PATH="/home/josh/.rvm/gems/ruby-2.1.5/bin:/home/josh/.rvm/gems/ruby-2.2.0/bin:/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"

in it.

.bashrc and .profile both have:

export PATH="$PATH:$HOME/.rvm/bin"

in them.

Should I have all of these in just one of the files and do multiple 'export' statements just get chained together when processed, even if from different files?

1
  • From the other questions asnwer: From the bash man page: When bash is invoked as an interactive login shell, ... it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. That seems to imply that only the first one that it can read will be read. Is that the case? If so, does that mean I should move all of the export PATH lines to .profile or they won't be read? Jan 18, 2015 at 23:12

1 Answer 1

-1

if you look inside .bashrc file there is line like this:

# Put your fun stuff here.

... or something like that.

So, this is the place reserved for user declarations, export, alias, etc ... the practice is to put all your export PATH="..." there, in .bashrc file after mentioned comment or just at the end of file.

3
  • No. .bashrc is for interactive shell settings (completion, prompt, etc.). .profile (or .bash_profile, etc.) is for things done at login time such as environment variable definitions. Jan 18, 2015 at 22:48
  • so .. the best place to define global variables are?
    – Scantlight
    Jan 18, 2015 at 22:56
  • .profile, or .pam_environment. See the duplicate question for more details. Jan 18, 2015 at 23:02

Not the answer you're looking for? Browse other questions tagged or ask your own question.