PLease HELP!!! PATH variable issue


 
Thread Tools Search this Thread
# 1  
PLease HELP!!! PATH variable issue

Hello,

I logged in to the unix solaris with my user name and then I again logged in with the sudo bash -l command

now when I do echo $PATH


It shows me => /usr/bin:/usr/local/bin:/usr/bin/usr/sbin:/usr/ucb:/usr/local/bin

How do i find out where is this file located for setting the PATH variable...

Also, If i installed jdk and tried setting PATH variable but everytime I logout and log back in I have to set it up again even though I export it ??? Why doesnt it propogate changes to all users or even on my re-login...Also, if i open one more putty window and try doing echo $PATH i dont see the path variable set to what i had set


Here is how I do it =>
JAVA_HOME= /usrJAVA/jdk1.6.0_25
export JAVA_HOME


PATH=$JAVA_HOME/bin:$PATH
export PATH
# 2  
Environment variables don't work that way, they're not global variables. All export means is that whatever child processes you create will get a copy of it.

When you login, your shell reads and runs lines from /etc/profile to set up environment variables and things, then maybe ~/.profile or something like it to set up your personal preferences. For BASH this is ~/.bash_profile. Put export variable=whatever in your ~/.bash_profile and it should get run when you run bash -l.
# 3  
if i go to etc/profile I see different path than /usr/bin:/usr/local/bin:/usr/bin/usr/sbin:/usr/ucb:/usr/local/bin


So where is this PATH variable located?

---------- Post updated at 03:58 PM ---------- Previous update was at 03:56 PM ----------

Quote:
Originally Posted by Corona688
Put export variable=whatever in your ~/.bash_profile and it should get run when you run bash -l.
So for setting global variable which means if i log in to 2 instances of putty and see the same path variable I need to modify ~/.bash_profile??? Is that correct???


What about the .profile in my home directory?? How is that different??
# 4  
Quote:
Originally Posted by siddhans
if i go to etc/profile I see different path than /usr/bin:/usr/local/bin:/usr/bin/usr/sbin:/usr/ucb:/usr/local/bin


So where is this PATH variable located?
These files are scripts. It's possible for PATH to be set in more than one location -- .bash_profile could add to the end of a PATH set by /etc/profile, for example.
Quote:
So for setting global variable
I repeat, they're not global variables.
Quote:
which means if i log in to 2 instances of putty and see the same path variable I need to modify ~/.bash_profile??? Is that correct???
I don't know why you'd expect to see two different PATHs when you logged in twice, but yes, you can put the changes you want into ~/.bash_profile.
Quote:
What about the .profile in my home directory?? How is that different??
.profile is what ksh uses, .bash_profile is what bash uses. Different local profiles for different shells make sense, otherwise you could end up with bash-specific commands causing ksh to throw up and ksh specific commands causing bash to throw up.

Again, these are script files, so it's possible for them to source other files too. Look at what's in them.
 

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #813
Difficulty: Medium
The CSS RGBA alpha parameter defines the opacity as a number between 1.0 (fully transparent) and 0.0 (fully opaque).
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

ksh - variable to be set to windows path issue

Greetings Experts, I need to pass a parameter to ksh and the value is windows path eg: sh abc.txt C:\Users\chill3chee\Desktop No matter I try with \ delimiter, still could not get this exact value assigned to the shell variable which was checked with echo. Tried with using... (2 Replies)
Discussion started by: chill3chee
2 Replies

2. Shell Programming and Scripting

Variable value substitution issue with awk command issue

Hi All, I am using the below script which has awk command, but it is not returing the expected result. can some pls help me to correct the command. The below script sample.ksh should give the result if the value of last 4 digits in the variable NM matches with the variable value DAT. The... (7 Replies)
Discussion started by: G.K.K
7 Replies

3. Shell Programming and Scripting

LaunchAgent file path issue

This is weirdly a linux question I suppose. Im having a problem with this code the file path is fine if I don't use the ~ and put in the user /Users/tempuser/.... This will be installed on more than one computer and changing the plist for every install is going to become tedious. Is there... (1 Reply)
Discussion started by: digitalviking
1 Replies

4. Shell Programming and Scripting

Path a variable to sed that includes a path

Hi I'm trying to select text between two lines, I'm using sed to to this, but I need to pass variables to it. For example start="BEGIN /home/mavkoup/data" end="END" sed -n -e '/${start}/,/${end}/g' doesn't work. I've tried double quotes as well. I think there's a problem with the / in the... (4 Replies)
Discussion started by: mavkoup
4 Replies

5. Shell Programming and Scripting

Appending a path in user's PATH variable

Hello Folks, I want to append a path in user's PATH variable which should be available in current session. Background Numerous persons will run a utility. Aim is to add the absolute path of the utility the first time it runs so that next runs have the PATH in env & users can directly run... (6 Replies)
Discussion started by: vibhor_agarwali
6 Replies

6. Shell Programming and Scripting

one liner to extract path from PATH variable

Hi, Could anyone help me in writing a single line code by either using (sed, awk, perl or whatever) to extract a specific path from the PATH environment variable? for eg: suppose the PATH is being set as follows PATH=/usr/bin/:/usr/local/bin:/bin:/usr/sbin:/usr/bin/java:/usr/bin/perl3.4 ... (2 Replies)
Discussion started by: royalibrahim
2 Replies

7. Shell Programming and Scripting

remove a path from PATH environment variable

Hi I need a script which will remove a path from PATH environment variable. For example $echo PATH /usr/local/bin:/usr/bin:test/rmve:/usr/games $echo rmv test/rmve Here I need a shell script which will remove rmv path (test/rmve) from PATH... (9 Replies)
Discussion started by: madhu84
9 Replies

8. UNIX for Dummies Questions & Answers

issue with PATH

hello On Debian Lenny, I first ran apt-get install git-core and then removed it to install from source. The trouble is that when I typed git --version, I am get: -bash: /usr/bin/git: No such file or directory of course, git is now in /usr/local/bin I don't understand why since... (1 Reply)
Discussion started by: JCR
1 Replies

9. Red Hat

PATH issue on linux

If PATH is set to ../bin:../sbin:/usr/bin:/usr/local/bin (chunk of path string). Sometime when I try to execute ls command it says ../bin/ls not found. According to my understanding "ls" should be searched in all the path varibales that we set in the PATH varaibale. Is there any reason for the... (5 Replies)
Discussion started by: hansini
5 Replies

10. Shell Programming and Scripting

Sed variable substitution when variable constructed of a directory path

Hello, i have another sed question.. I'm trying to do variable substition with sed and i'm running into a problem. my var1 is a string constructed like this: filename1 filerev1 filepath1 my var2 is another string constructed like this: filename2 filerev2 filepath2 when i do... (2 Replies)
Discussion started by: alrinno
2 Replies

Featured Tech Videos