Quote:
Originally Posted by oouc
I kept losing my path in Ubuntu 8.04 after running a certain program. Any help would be greatly appreciated.
js@hh:/media/hda9/56/programming/ide/jEdit/4.3pre12$ cat /media/hda9/56/programming/java/SetPath1_6_07.txt
/usr/local/bin/jdk1.6.0_07/bin:/usr/local/bin/jdk1.6.0_07/jre:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
js@hh:/media/hda9/56/programming/ide/jEdit/4.3pre12$ sudo echo $Path
<snip>
js@hh:/media/hda9/56/programming/ide/jEdit/4.3pre12$ export PATH=/usr/local/bin/jdk1.6.0_07/bin:/usr/local/bin/jdk1.6.0_07/jre:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
js@hh:/media/hda9/56/programming/ide/jEdit/4.3pre12$ echo $PATH
/usr/local/bin/jdk1.6.0_07/bin:/usr/local/bin/jdk1.6.0_07/jre:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
js@hh:/media/hda9/56/programming/ide/jEdit/4.3pre12$
|
Now that I read your original post again I can see that when you sudo to root to echo $PATH you have misspelled $PATH as $Path. So that's why that doesn't show any PATH.
The end shows that you set $PATH in the normal user account and then echo $PATH so that's why you have what you see in the last section.
So it looks like you are trying to list $PATH under the root account but you misspelled $PATH so you see nothing, then you export $PATH as a normal user and then list $PATH as that same normal user.
I'm going to make a big leap in guesswork to try to understand what you are thinking.
It seems that you believe that the first line in your example code should set your process path but it doesn't because the text file does not contain a verb. The text file simply contains the value that you want to use for your normal user PATH but you don't have a verb in the script so it is not a script. Even if it were a script you would ALSO have to have the execute permission bit set on the file. Maybe the execute permission bit is set or maybe it isn't. We don't know at this point. Your SetPath1_6_07.txt file should contain a verb such as you see in the following code example.
Code:
export PATH="/bin:/usr/bin"
Notice here the verb is export. Actually there are two verbs since the = symbol is also a verb. But running this won't set your PATH for your current process because when you run a script the bash shell spawns a child process to run the script. If you want a script to set your PATH for your current process then you have to "source" the script. That is a special verb in bash that tells the command interpreter to run the script in the current process. Here is an example.
Code:
. SetPath1_6_07.txt
You would do that at the command line.
Then you sudo to root and echo $PATH but since you misspelled $PATH you see nothing. I believe you expect that the PATH that you thought that you set under the normal user account should export to the root login under sudo but it won't. When you use sudo it is a separate login for root and nothing from your normal user environment will export to the root environment.
The last section is the first time that you successfully set PATH anywhere in the example code. Naturally when you then echo $PATH it shows the value that you had just set in the PATH variable. I want to emphasize that this is the first time that you successfully set the PATH variable anywhere in your example code.
I hope this helps. I wouldn't have taken the time to write this if I didn't sincerely want to help you to understand. If I have misunderstood your question please let me know.