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 01-12-2011, 10:04 AM   #1
rbigelow
LQ Newbie
 
Registered: Jan 2011
Posts: 4

Rep: Reputation: 0
Messed Up PATH Variable, Unable to use commands....


Hi guys, so I messed something up on my machine and now I'm having a ton of issues un-doing it. This is what is shown on login, also vi, locate, grep and a bunch of other commands are subsequently not working. VI is especially annoying because I can't edit any files to try and undo my error. Any help would be appreciated.

-bash: /usr/java/jdk1.6.0_13/bin: is a directory
-bash: id: command not found
-bash: id: command not found
 
Old 01-12-2011, 10:19 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
Hi,

It looks like that the PATH variable isn't set. It could be just that, but it could also be that other things are not working as wanted/needed, only you know what you have done.

The PATH variable makes life very easy, but one can work without it.

You can run every command by appending the full path. To run vi you need to run /usr/bin/vi (or /bin/vi).

Hope this helps.

PS: Once you find out what is wrong we might be able to get you on track again.
 
Old 01-12-2011, 10:28 AM   #3
rbigelow
LQ Newbie
 
Registered: Jan 2011
Posts: 4

Original Poster
Rep: Reputation: 0
echo $PATH return "/usr/kerberos/bin:/usr/java/jdk1.6.0_13/bin:/bin:/usr/local/bin:/home/rbigelow/bin"

I believe the commands that broke it may have been the following:

echo 'export JAVA_HOME=/usr/java/jdk1.6.0_11'>/etc/profile.d/jdk.sh
echo 'export PATH=$JAVA_HOME/bin:$PATH'>>/etc/profile.d/jdk.sh
source /etc/profile.d/jdk.sh

does that help?
 
Old 01-12-2011, 10:46 AM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
Hi,
Quote:
echo $PATH return "/usr/kerberos/bin:/usr/java/jdk1.6.0_13/bin:/bin:/usr/local/bin:/home/rbigelow/bin"
There is at least one directory missing from that output: /usr/bin

Quote:
I believe the commands that broke it may have been the following:

echo 'export JAVA_HOME=/usr/java/jdk1.6.0_11'>/etc/profile.d/jdk.sh
echo 'export PATH=$JAVA_HOME/bin:$PATH'>>/etc/profile.d/jdk.sh
source /etc/profile.d/jdk.sh
I don't think this is the problem (although I cannot be 100% sure). (see post #8)

How and where PATH is set depends a bit on your distro. Which distro are you using?

What is the output of: grep PATH /etc/profile?

Last edited by druuna; 01-12-2011 at 04:06 PM. Reason: Oops.....
 
Old 01-12-2011, 11:42 AM   #5
rbigelow
LQ Newbie
 
Registered: Jan 2011
Posts: 4

Original Poster
Rep: Reputation: 0
[rbigelow@rbigelownx1 ~]$ grep PATH /etc/profile?
grep: /etc/profile?: No such file or directory
 
Old 01-12-2011, 11:52 AM   #6
rbigelow
LQ Newbie
 
Registered: Jan 2011
Posts: 4

Original Poster
Rep: Reputation: 0
Figured out my issue, I had "export PATH=$JAVA_HOME/bin:$PATH" saved in /etc/profile.d/jdk.sh file and once I removed it my issue resolved itself. Thanks for the help
 
Old 01-12-2011, 03:46 PM   #7
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
Hi,

Glad to see you got it resolved

Quote:
[rbigelow@rbigelownx1 ~]$ grep PATH /etc/profile?
grep: /etc/profile?: No such file or directory
The question mark is part of the question (What is the output of: grep PATH /etc/profile ?), not part of the command (grep PATH /etc/profile).

Can you put up the solved tag (first post -> Thread Tools).
 
Old 01-12-2011, 03:56 PM   #8
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Quote:
Originally Posted by rbigelow View Post
Code:
echo 'export JAVA_HOME=/usr/java/jdk1.6.0_11'>/etc/profile.d/jdk.sh
echo 'export PATH=$JAVA_HOME/bin:$PATH'>>/etc/profile.d/jdk.sh
source /etc/profile.d/jdk.sh
The problem here are the single ticks ...

They won't evaluate the actually set shell-variables, but put nonsense
values "$JAVA_HOME" and "$PATH" into the PATH literally, while only
tacking /usr/java/jdk1.6.0_11/bin in the variable as an actual path.


Replace them w/ "" and you should be fine; actually, for good style
and best practice, maybe use
Code:
export PATH="${PATH}:${JAVA_HOME}/bin:${JAVA_HOME}/jre/bin"


Cheers,
Tink
 
Old 01-12-2011, 04:04 PM   #9
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
Hi Tinkster,

Oh my, that I missed that one
 
Old 01-12-2011, 04:40 PM   #10
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Quote:
Originally Posted by druuna View Post
Hi Tinkster,

Oh my, that I missed that one
No worries - I bet I have more blonde (senior, idiotic, ... ) moments
than you do ;}



Cheers,
Tink
 
  


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
[SOLVED] My PATH variable was changed accidently and now I cant find any commands on my termin anushya.k.kutty Linux - Newbie 12 04-15-2010 10:20 AM
commands with variable nagavinodh Linux - Newbie 3 12-11-2009 01:12 AM
Add path to $PATH variable alaios SUSE / openSUSE 2 04-19-2009 09:41 AM
bash script path issue - how to pass a path as a string to a variable PiNPOiNT Programming 5 04-17-2009 06:48 PM
I think I messed up my PATH... tcv Linux - Software 11 01-08-2005 11:41 PM


All times are GMT -5. The time now is 02:56 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