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-22-2010, 11:06 PM   #1
your_shadow03
Senior Member
 
Registered: Jun 2008
Location: Germany
Distribution: Slackware
Posts: 1,461
Blog Entries: 6

Rep: Reputation: 51
Help with $PATH variable Setup?


One of my colleague ran into trouble with setting up of path variable.
Earlier the entry for PATH in /etc/profile was:

Code:
echo $PATH
/usr/local/bin:/bin:/usr/bin:/home/myname/bin:/sbin
Now what he mistake is:
He added a new Lines at the end as

Code:
LD_LIBRARY=/opt/tptp/linux_em94/bin
export PATH
Now due to this he is unable to run commmands now because that has overwritten the earlier PATH varaible.
If he types now:

echo $PATH
It shows:
Code:
/opt/tptp/linux_em94/bin
How Can he get rid of the same?
 
Old 01-22-2010, 11:46 PM   #2
neonsignal
Senior Member
 
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Jessie (Fluxbox WM)
Posts: 1,387
Blog Entries: 52

Rep: Reputation: 355Reputation: 355Reputation: 355Reputation: 355
From the command line, you can reset the path.

Code:
PATh=/usr/local/bin:/bin:/usr/bin:/home/myname/bin:/sbin
Then you can edit /etc/profile and fix the problem.
 
Old 01-22-2010, 11:48 PM   #3
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian Jessie 8.4
Posts: 5,873

Rep: Reputation: 348Reputation: 348Reputation: 348Reputation: 348
It's easy to correct.

Su to root, then issue this command:
export PATH=/usr/local/bin:/bin:/usr/bin:/home/myname/bin:/sbin


That should overwrite the current PATH variable.

Last edited by bigrigdriver; 01-22-2010 at 11:50 PM.
 
Old 01-22-2010, 11:57 PM   #4
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
The lines shown would not change the value of PATH. When you wrote "He added a new Lines at the end as", where did he write the new lines, at the end of what?

Perhaps the mistake was to add new lines
Code:
PATH=/opt/tptp/linux_em94/bin
export PATH
If so, neonsignal's technique can be used to fix the error in the changed file.
 
Old 01-23-2010, 12:05 AM   #5
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 that re-booting resets the PATH variable---If you rummage around in the startup scripts, you will see various places where PATH is set.
 
Old 01-23-2010, 12:56 AM   #6
your_shadow03
Senior Member
 
Registered: Jun 2008
Location: Germany
Distribution: Slackware
Posts: 1,461
Blog Entries: 6

Original Poster
Rep: Reputation: 51
Why does the new line entry:

Code:
PATH=/opt/tptp/linux_em94/bin
export PATH
eliminated the earlier line PATH variable.
Does it read line by line.
 
Old 01-23-2010, 01:06 AM   #7
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
Pixellany is certainly correct in post #5 -- rebooting will bring the path back to normal. You might also try going to init level 1, and back again to whatever runlevel you are at now. That should fix it too. Or, try sourcing /etc/profile or whatever is the equivalent file on the system in question.

Note: In your first post, you wrote that your friend (or whoever) did the following:

LD_LIBRARY=/opt/tptp/linux_em94/bin
export PATH


And then his $PATH showed this:

/opt/tptp/linux_em94/bin

But something is amiss there; If the above is what he did, then $PATH would be empty. Perhaps you omitted a step?

In any event, if you (re)define a common environment variable, and then export it, it becomes part of that shell's environment. But it is only 'temporary'-- it isn't a permanent change to the system. You could say PATH="ogopogo and orange juice" end export it, and your path would be just that, until you exit that shell and/or reset the path and/or reboot.

Of course, if he edited /etc/profile and made a silly path in there, all that need be done is to fix that file, and reboot (or maybe go to init 1 and back to init 3/4/5) and it will be fixed.

PS - Yes, it reads line by line. So if you set PATH 5 times in a row, it will be overwritten (reset) each time, and will only end up containing the most recent bunch of items. This is why, when ADDING stuff to a PATH, we usually do:
PATH="$(PATH}:/new/entry:/more/stuff:/bin/weird/location:." so that the NEW stuff gets added to the already existing stuff.

Sasha

Last edited by GrapefruiTgirl; 01-23-2010 at 01:10 AM.
 
Old 01-23-2010, 01:09 AM   #8
neonsignal
Senior Member
 
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Jessie (Fluxbox WM)
Posts: 1,387
Blog Entries: 52

Rep: Reputation: 355Reputation: 355Reputation: 355Reputation: 355
Quote:
eliminated the earlier line PATH variable.
The second assignment overwrites the first one in /etc/profile. It should have been:
Code:
PATH=$PATH:/opt/tptp/linux_em94/bin
export PATH
 
  


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
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
Path Variable answerme Linux - Newbie 6 04-19-2008 03:35 AM
PATH variable suavecu Linux - Software 11 01-28-2006 01:44 AM
$path variable ? moby Linux - Newbie 3 06-01-2004 04:18 PM


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