PATH From ~/.profile is only added when logging in remotely
Hello, in my ~/.profile I have this line:
Code:
PATH=$HOME/bin:$PATH When I log in remotely, using ssh, the PATH=$HOME/bin:$PATH is added: Code:
:~$ echo $PATH Code:
~$ echo $PATH |
|
Thanks weibullguy, but doesn't it say ~/.profile will be read, if you do not have ~/.bash_profile and ~/.bash_login?
Quote:
|
The thing is you need to understand the difference between a login and non-login shell. When you login remotely, you invoke a login shell, but a shell opened from a GUI is a non-login shell (since you're already logged in).
What I like to do is have .bash_profile source .bashrc. The .bashrc file is always read, regardless of whether the shell is a login shell or not. |
Ok, thanks btmiller, I may be starting to understand, although it doesn't make a lot of sense at the moment.
If I login remotely, a login shell is used, so .profile is read. Ok up to here. When I login locally, using the GUI login screen, is .profile read? Once logged in, if I open a terminal window, that will be a non-login shell, so .profile is not read. However, since I am already logged in, shouldn't my PATH variable already have been set from .profile? Also I may have previously logged in remotely, so .profile has already been read. Does each instance of me logging in create a different user shell, where changes from other shells are not seen? If that makes sense. If you could, what did you mean by 'have .bash_profile source .bashrc'? Thanks! |
It seems fixed now.
I created a new .bash_profile, with 'source bashrc' code from the .profile file: Code:
~$ cat .bash_profile Code:
# set PATH so it includes user's private bin if it exists Also, less important now, but which of these files is read when first logging in from the GUI login screen? |
I think you can safely delete .profile now (might want to make a back-up copy).
When you login to the GUI, what gets run is entirely dependent on what desktop and window manager you are using. X11 itself reads ~/.xinitrc or its global equivalent, which usually just contains commands to start the window manager or desktop environment. Since a GUI desktop is not a shell, there's not something really 100% equivalent to the profile file that gets sourced. |
Thanks! I'll mark the thread solved.
|
All times are GMT -5. The time now is 01:21 AM. |