Linux - GeneralThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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.
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.
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
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"
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.