LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-14-2010, 07:58 AM   #1
anushya.k.kutty
LQ Newbie
 
Registered: Apr 2010
Posts: 10

Rep: Reputation: 0
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??
 
Old 04-14-2010, 08:03 AM   #2
PMP
Member
 
Registered: Apr 2009
Location: ~
Distribution: RHEL, Fedora
Posts: 381

Rep: Reputation: 58
Where you change the PATH variable?

To give more priority to java 6 add the path to java 6 bin before java 5 bin
 
Old 04-14-2010, 09:17 AM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
I think the PATH variable will be restored when you boot up.
 
Old 04-14-2010, 09:37 AM   #4
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 720Reputation: 720Reputation: 720Reputation: 720Reputation: 720Reputation: 720Reputation: 720
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
 
Old 04-14-2010, 10:37 AM   #5
alli_yas
Member
 
Registered: Apr 2010
Location: Johannesburg
Distribution: Fedora 14, RHEL 5.5, CentOS 5.5, Ubuntu 10.04
Posts: 559

Rep: Reputation: 92
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.
 
Old 04-14-2010, 02:27 PM   #6
anushya.k.kutty
LQ Newbie
 
Registered: Apr 2010
Posts: 10

Original Poster
Rep: Reputation: 0
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..
 
Old 04-14-2010, 02:37 PM   #7
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 720Reputation: 720Reputation: 720Reputation: 720Reputation: 720Reputation: 720Reputation: 720
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.
 
Old 04-15-2010, 12:46 AM   #8
bsat
Member
 
Registered: Feb 2009
Posts: 347

Rep: Reputation: 72
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.
 
Old 04-15-2010, 09:43 AM   #9
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Quote:
Originally Posted by anushya.k.kutty View Post
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

Last edited by pixellany; 04-15-2010 at 09:44 AM.
 
Old 04-15-2010, 09:47 AM   #10
PMP
Member
 
Registered: Apr 2009
Location: ~
Distribution: RHEL, Fedora
Posts: 381

Rep: Reputation: 58
Quote:
Originally Posted by anushya.k.kutty View Post
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 $
 
Old 04-15-2010, 09:48 AM   #11
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 720Reputation: 720Reputation: 720Reputation: 720Reputation: 720Reputation: 720Reputation: 720
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.
 
Old 04-15-2010, 09:54 AM   #12
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
Quote:
Originally Posted by pixellany View Post
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 View Post
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 "=".
 
Old 04-15-2010, 10:20 AM   #13
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Sorry----I fixed two errors in the original, but missed the third one

Assigning variables:
varname=<stuff>

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script path issue - how to pass a path as a string to a variable PiNPOiNT Programming 5 04-17-2009 06:48 PM
how to set a variable in a script and have the variable still set after script termin john test Linux - Newbie 9 10-21-2008 06:21 PM
changed the value of PATH variable shamiksaha Linux - Newbie 1 06-05-2008 04:41 PM
Path changed, I cant find where the problem is kramed Fedora 3 03-27-2008 02:25 PM
accidently changed root privileges GhostCow Ubuntu 12 09-05-2007 06:49 AM


All times are GMT -5. The time now is 06:33 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration