LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 11-19-2008, 08:42 AM   #1
spangler
Member
 
Registered: Apr 2007
Posts: 45
Blog Entries: 1

Rep: Reputation: 15
Editing the PATH Environment Varialbe


Hello everyone,

I am trying to clear up some Environment Variables that are set in my PATH that do not exist. I tried to delete them from the PATH but they just keep coming back. The way that I am doing this is by copying the PATH to a text editor deleting the ones that do not belong and then adding the PATH back:

PATH=$PATH:/dir/dir/dir
export PATH

Am I doing something wrong? The paths keep coming back. I looked in the .bashrc file and found nothing. It is just specific to this user. Where else should I look?
 
Old 11-19-2008, 09:01 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
Well, the better thing to do is to locate the place where these specific directories are added to the path and remove them from the source. If you are sure they are for one user only, you have to look in all the configuration files under the user's home directory. For example, suppose you want to remove /path/to/some/dir from PATH:
Code:
find /home/user -type f -print0 | xargs -0 grep "/path/to/some/dir"
otherwise do the same as root using /etc as starting point for the find command. Also take in mind that in the path definition a script may use some environment variable like $HOME. So, if you want to locate where /home/user/some/path is added, you have to grep for "/some/path" only.

Last edited by colucix; 11-19-2008 at 09:03 AM.
 
Old 11-19-2008, 11:24 AM   #3
sydney-troz
Member
 
Registered: Feb 2007
Distribution: Kubuntu, it's obese barely-usable sibling, Ubuntu
Posts: 142

Rep: Reputation: 15
The reason what you were doing wasn't working, spangler, was that environment variables for a shell are loaded from config files each time a new shell is spawned -- the only thing calling "export" does is cause the shell from which you export the variable to copy it to any child processes.

For example, if you're using bash, your PATH is setup in either ~/.bashrc (for all interactive shells) or one of (~/.profile or ~/.bash_profile) (for login shells). Changing an env. variable directly only affects the process from which the change was made.
 
Old 11-20-2008, 10:26 AM   #4
spangler
Member
 
Registered: Apr 2007
Posts: 45
Blog Entries: 1

Original Poster
Rep: Reputation: 15
Thank you for the advice colucix

I tried to use the find /home/user -type f -print0 | xargs -0 grep "/usr/lib/mit/bin and all it did was bring me to a

>

There was nothing displayed. Did I type something wrong? The path /usr/lib/mit/bin does not exist. I will continue to look through the config files in the users home directory
 
Old 11-20-2008, 10:42 AM   #5
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
Quote:
Originally Posted by spangler View Post
I tried to use the find /home/user -type f -print0 | xargs -0 grep "/usr/lib/mit/bin and all it did was bring me to a

>

There was nothing displayed. Did I type something wrong?
Yes, you missed the closing double quotes. For this reason the shell still waits for input and shows the secondary prompt ">". Moreover, substitute the real username in the starting search point. For example:
Code:
find /home/spangler -type f -print0 | xargs -0 grep "/usr/lib/mit/bin"
 
Old 11-21-2008, 09:00 AM   #6
spangler
Member
 
Registered: Apr 2007
Posts: 45
Blog Entries: 1

Original Poster
Rep: Reputation: 15
colucix,

You were right. The ending " was not there. That worked much better. Now I have lots of files to browse through to see if I can get this fixed. Thank you for all your help. I will keep this post updated when I get through everything.
 
Old 11-21-2008, 11:02 AM   #7
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
Quote:
Originally Posted by spangler View Post
I will keep this post updated when I get through everything.
Well done. See you soon!
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Editing $PATH on SUSE 10.1 jCash Linux - Newbie 5 02-15-2007 03:48 PM
editing $PATH resist_r Linux - Newbie 3 07-09-2005 10:33 PM
PATH statement editing? cottonmouth Linux - General 2 08-17-2003 09:00 PM
PATH editing... Jester888 Linux - Newbie 2 01-23-2002 09:13 PM
Editing the PATH Cichlid Linux - General 3 01-06-2002 08:47 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:32 PM.

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