Turb0flat4 Posted April 20, 2006 Report Share Posted April 20, 2006 I need to reset my $PATH to include my path to java (/usr/java/jdk1.5.0_06/bin) so I did this : export PATH=$PATH:/usr/java/jdk1.5.0_06/bin when I did this from the same term echo $PATH it included the new addition. However, when I did the same from a new shell which I opened, the PATH reverted to the old one. From my limited reading isn't "export PATH" supposed to add to the PATH variable for all subsequently opened terminals ? In any case, I added the PATH to my ~/.bash_profile, so I'll get it next time I reboot. But I want to have this in my global PATH without rebooting, how to do it ? Thanks. Quote Link to comment Share on other sites More sharing options...
scarecrow Posted April 20, 2006 Report Share Posted April 20, 2006 (edited) If you put the export command in ~/.bash_profile, then logging out and then back in is enough. If you put the command to a system wide (global) script, then you can (instead of rebooting) going telinit 1 and then back to telinit 5. Of couse going telinit 1 will stop some services temporarily. Edited April 20, 2006 by scarecrow Quote Link to comment Share on other sites More sharing options...
neddie Posted April 20, 2006 Report Share Posted April 20, 2006 I just have the line "PATH=$PATH:/usr/...whatever..." in my ~/.bashrc file, I don't need to reboot for this to take effect, I just need to open another console. Is there a difference between .bash_profile and .bashrc? Quote Link to comment Share on other sites More sharing options...
iphitus Posted April 20, 2006 Report Share Posted April 20, 2006 You cannot change it for your current running X session. Only newly started shells or ones you have access to. The best way is to set it in your bashrc, and then dont reboot, just logout, and back in again. Quote Link to comment Share on other sites More sharing options...
Turb0flat4 Posted April 21, 2006 Author Report Share Posted April 21, 2006 (edited) I restarted the session and could get the new PATH. I just thought there's a way to get the new PATH working for all terminals without logging out (by logging out, I stopped running processes like my Azureus). I really thought export PATH would do it. That was what I got from this website : http://club.mandriva.com/xwiki/bin/KB/BasicsBshell5 export PATH=$PATH:/some/directory If you now open a new terminal and type echo $PATH, you will see the new value of $PATH in this terminal, too. Notice, however, that the 'export' command only sets or changes variables for the terminal it is run in and terminals which are started after it has been run. Terminals which were already open will still have the old $PATH. Edited April 21, 2006 by Turb0flat4 Quote Link to comment Share on other sites More sharing options...
iphitus Posted April 21, 2006 Report Share Posted April 21, 2006 it will only affect terminals/processes that are started after you set it. what happens, is that processes inherit environmental variables from their parent process, and so when you start X, all the GUI apps that start inherit their variables from when you started. if you for example, click an icon on your kde panel, it will inherit PATH from the panel, which inherited at startup. the only way to reload the PATH to these apps, is to restart them. James Quote Link to comment Share on other sites More sharing options...
Turb0flat4 Posted April 21, 2006 Author Report Share Posted April 21, 2006 it will only affect terminals/processes that are started after you set it. what happens, is that processes inherit environmental variables from their parent process, and so when you start X, all the GUI apps that start inherit their variables from when you started. if you for example, click an icon on your kde panel, it will inherit PATH from the panel, which inherited at startup. the only way to reload the PATH to these apps, is to restart them. James But even if I open up a Konsole window, do the export PATH thing and then try to open a new shell or a new window from that previous Konsole, the PATH in the newly spawned Konsole windows is stil the default PATH, not the new one I set. Just trying to understand under what circumstances I can do this. Thanks. Quote Link to comment Share on other sites More sharing options...
ianw1974 Posted April 21, 2006 Report Share Posted April 21, 2006 You can't, because it pulls stuff from your .bashrc file, and also from /etc/profile. If it's not specified in any of these, it will not pick the new statement. You have to add it to one of these files, and log out of the system. If you don't log out, it won't pick up the new path statement, no matter what you try right now. This is because your system is running on the previous environment variables BEFORE you typed the path statement. And it won't pick up anything you type subsequently. You have to add it to a file, and then log off and back on again. Quote Link to comment Share on other sites More sharing options...
Turb0flat4 Posted April 21, 2006 Author Report Share Posted April 21, 2006 So basically "export PATH" is useless ? If I only want to change the PATH in one terminal, I can just do "PATH=$PATH:(extra stuff)" right ? I'm trying to see what use the "export" syntax has, right now, it looks useless to me. Quote Link to comment Share on other sites More sharing options...
neddie Posted April 21, 2006 Report Share Posted April 21, 2006 You have to add it to one of these files, and log out of the system. If you don't log out, it won't pick up the new path statement, no matter what you try right now. Not quite true, at least in my case. If I change my .bashrc and then open a new console, it does pick up the changed path statement. I don't have to log out and log back in again because the .bashrc is read and executed whenever a new bash session is started. If you want the change to also affect terminals which are already open, maybe there's a way to manually execute the .bashrc file from each one? I tried "bash .bashrc" but that didn't seem to work too well... Quote Link to comment Share on other sites More sharing options...
ianw1974 Posted April 21, 2006 Report Share Posted April 21, 2006 Ah, that's cool then, at least saves logging out. But what he was doing was just typing it in one terminal window, and expecting it to be active in a new one he opened. OK, so add your export line to the .bashrc file in your home directory, then it will work fine for you. It won't work when typed manually at the command line. Quote Link to comment Share on other sites More sharing options...
Turb0flat4 Posted April 22, 2006 Author Report Share Posted April 22, 2006 Yes, but I still don't see the exact difference b/w issuing "export PATH=..." compard to simply "PATH=..." Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.