[SOLVED] PATH From ~/.profile is only added when logging in remotely
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
Thanks weibullguy, but doesn't it say ~/.profile will be read, if you do not have ~/.bash_profile and ~/.bash_login?
Invoked as an interactive login shell, or with --login
When Bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, 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. The --noprofile option may be used when the shell is started to inhibit this behavior.
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'?
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.