LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   My PATH variable was changed accidently and now I cant find any commands on my termin (https://www.linuxquestions.org/questions/linux-newbie-8/my-path-variable-was-changed-accidently-and-now-i-cant-find-any-commands-on-my-termin-801964/)

anushya.k.kutty 04-14-2010 06:58 AM

My PATH variable was changed accidently and now I cant find any commands on my termin
 
I accidently changed my PATH variable and now i cant find any commands on my terminal .I am using Debian.How to solve this problem??
I also need to know how to give priority to java 6 if i hav both java 5 and java 6 installed in debian??

PMP 04-14-2010 07:03 AM

Where you change the PATH variable?

To give more priority to java 6 add the path to java 6 bin before java 5 bin

pixellany 04-14-2010 08:17 AM

I think the PATH variable will be restored when you boot up.

MTK358 04-14-2010 08:37 AM

Maybe a little unrelated, but even without a PATH, you can still access commands by typing their full path, like:

Code:

/bin/ls
/bin/mv
/usr/bin/vim


alli_yas 04-14-2010 09:37 AM

Which of your commands are you trying to access?

Unless you've backed up your profile somewhere; you'd need to have knowledge of exactly where the binaries are located for each of your apps (if not in /usr/bin; /usr/sbin).

Perhaps post the contents of /home/youruser/.bash_profile - this will indicate if you've completely lost your PATH.

anushya.k.kutty 04-14-2010 01:27 PM

I typed something like
export $JAVA_HOME= /home/username/...../jdk1.6.0_18
export $PATH=$PATH:JAVA_HOME/bin
in my .bashrc file inorder to set classpath for my java 6.
After setting it, i couldnt find my commands..

MTK358 04-14-2010 01:37 PM

I used a similar thing to add /home/username/bin to my $PATH, but I did it quite differently, and I put in in my .bash_profile instead of my .bashrc:

Code:

PATH="${PATH}:${HOME}/bin"
I see I used "VAR=" instead of "export $VAR=", I wonder if that could be it.

bsat 04-14-2010 11:46 PM

MTK could be right, if that also does not work, just remove these lines from your .bash_profile file and see if your commands start working.

pixellany 04-15-2010 08:43 AM

Quote:

Originally Posted by anushya.k.kutty (Post 3935530)
I typed something like
export $JAVA_HOME= /home/username/...../jdk1.6.0_18
export $PATH=$PATH:JAVA_HOME/bin
in my .bashrc file inorder to set classpath for my java 6.
After setting it, i couldnt find my commands..

In this example, it should have been:
export $PATH=$PATH:$JAVA_HOME/bin

Convention says use quotes on the right-hand side of =, but I just tried without quotes and it did not seem to matter.

And, don't use $ when assigning the variable---should be:
JAVA_HOME= /home/username/...../jdk1.6.0_18

PMP 04-15-2010 08:47 AM

Quote:

Originally Posted by anushya.k.kutty (Post 3935530)
I typed something like
export $JAVA_HOME= /home/username/...../jdk1.6.0_18
export $PATH=$PATH:JAVA_HOME/bin
in my .bashrc file inorder to set classpath for my java 6.
After setting it, i couldnt find my commands..

Remove this $

MTK358 04-15-2010 08:48 AM

So I guess the solution for the OP would be to remove what he but in his .bashrc and put this in his .bash_profile:

Code:

JAVA_HOME="$HOME/...../jdk1.6.0_18"
PATH="$PATH:$JAVA_HOME/bin"

I don't know what the "....." is, just replace it by what you meant.

catkin 04-15-2010 08:54 AM

Quote:

Originally Posted by pixellany (Post 3936427)
In this example, it should have been:
export $PATH=$PATH:$JAVA_HOME/bin

Is there a typo in that? Should it not be (as suggested for export JAVA=...)
Code:

export PATH=$PATH:$JAVA_HOME/bin
Quote:

Originally Posted by pixellany (Post 3936427)
Convention says use quotes on the right-hand side of =, but I just tried without quotes and it did not seem to matter.

It was prudent in earlier shells (in case there was whitespace in the value of $PATH) but is not necessary in recent (all?) bash versions because bash does not do word splitting on the expression to the right of an assignment "=".

pixellany 04-15-2010 09:20 AM

Sorry----I fixed two errors in the original, but missed the third one

Assigning variables:
varname=<stuff>

Using variables:
<stuff>=$varname <other stuff>


All times are GMT -5. The time now is 01:59 PM.