quick question about PATH variable
Newbie question here. I updated my PATH with export PATH=$PATH:new_directory and I was able to access programs in the new directory but my PATH was reset the next time I logged in. Do I need to save my settings when I make a change like this? If so how?
Thanks |
When you use the command line to do this, it sets the variable for your current shell. If you switch to another terminal and echo $PATH, you'll see it hasn't been changed there.
You need to add the changes to the right config file for your shell. For example, if you use bash, look in your home dir for .bash_profile or .bashrc - one of those files will have some commands that are always executed in a new shell. Add your updated PATH line to that file, then log out and back in again to test. |
thanks CroMagnon
|
by the way if I don't have either .bash_profile or .bashrc is there another place where I could find it or do I need to create it?
also what specifically do I need to add to the file? thanks |
Another possibility is .profile... also, make sure you are listing all files (i.e ls -A), since they are hidden by default.
What you add to the file depends on what you find already in it... normally people set the variables needed via straight assignment and export them at the end (scripts run in a subshell, export sends one or more vars to the parent shell). There's a good chance your PATH is set and exported already, but the maximum you would have to add to the file is this: PATH=$PATH:new_dir export PATH |
All times are GMT -5. The time now is 05:51 AM. |