There is always a confusion on which dot file to use to initialise environment variables under unix (i.e) .bash_profile , /etc/profile , .bashrc, .bash_login et.al?
There is two different types of shells called login shell & interactive shell and each has it own sequence of dot files to look for while starting. How do you differentiate them ? When trying to remotely login through ssh or any shell which asks to login is considered as login shell.
In the case of a login shell, the /etc/profile file is sourced first. Then it looks for the files in below sequence
In the case of a interactive shell, then it looks for ~/.bashrc and executes it if present.
On my setup what ideally I do is to keep my environment variables in ~./profile file as the subshell (or) subprocess would inherit that. All the alias definitions would go into the ~/.bashrc file.
A good reference is available here
There is two different types of shells called login shell & interactive shell and each has it own sequence of dot files to look for while starting. How do you differentiate them ? When trying to remotely login through ssh or any shell which asks to login is considered as login shell.
In the case of a login shell, the /etc/profile file is sourced first. Then it looks for the files in below sequence
.bash_profile -> ~/.bash_login -> .profile and whichever is found first & readable is executed.
In the case of a interactive shell, then it looks for ~/.bashrc and executes it if present.
On my setup what ideally I do is to keep my environment variables in ~./profile file as the subshell (or) subprocess would inherit that. All the alias definitions would go into the ~/.bashrc file.
A good reference is available here