Login Shell :
SSH
Non login Shell :
Login into graphic GUI(MAC), open up terminal
For Login Shell :
system checks .bash_profile and .bash_login first it they do not exist, system reads .profile
Rules :
Some things from my own
.bashrc (as an example):- Set
$PS1 - Enable special tab completion rules
- Set shell options by running
shopt - Set up command aliases
From my
.bash_profile:- Source
.bashrc - Add directories to
$PATH - Run
ssh-agent
Non login shell:
does not read .bash_profile or .profile
but it can always be manual run
- Because terminals don't usually run login shells by default. They also usually have options to run login shells, which do source
.profile. - To control the behaviour of login shells.
- Depends on the shell. For
bash, see the set of startup files. - Not in some sense (updating login records, for example).
- If you have a folder called
binin$HOME, the default.profilefor Ubuntu does add it to yourPATH. Since.profileis sourced at login (even with a GUI login), it should be part of yourPATHfor non-login shells started after a re-login. It isn't wrong if a directory appears twice inPATH, see this U&L question for details.
source vs sh
sh foo.sh runs the script within the context of a new sh shell, which on many OSes is not even Bash (which may be one reason the script doesn't work). source is a bash-only built-in command. That means when you call source , there is no executable like /bin/source or so.
source ~/.bash_profile or . ~/.bash_profile
sh bla.sh or ./ bla.sh
No comments:
Post a Comment