Views:
10,508
Votes: 4
Tags:
bash
java
environment-variables
bashrc
Link:
🔍 See Original Answer on Ask Ubuntu ⧉ 🔗
URL:
https://askubuntu.com/q/1069939
Title:
Where is my PATH variable being set?
ID:
/2018/08/28/Where-is-my-PATH-variable-being-set_
Created:
August 28, 2018
Edited: September 30, 2018
Upload:
September 15, 2024
Layout: post
TOC:
false
Navigation: false
Copy to clipboard: false
To find all places where $PATH
environment variable is changed use this:
sudo grep -rnw --exclude-dir={boot,dev,lib,media,mnt,proc,root,run,sys,/tmp,tmpfs,var} '/' -e "PATH="
This will search all directories on your system excluding virtual file system directories. In my case with three distros mounted, 697 files are returned.
A more targeted approach for OP is to search for specific path name. You could look for the program that is setting the unusual part of $PATH containing:
/usr/local/java/jdk1.7.0_79/bin
Run this in the terminal:
sudo grep -rnw --exclude-dir={boot,dev,lib,media,mnt,proc,root,run,sys,/tmp,tmpfs,var} '/' -e "/usr/local/java/jdk1.7.0_79/bin"
If the first directory in the $PATH is not the culprit then search for the last one:
/usr/lib/jvm/java-7-openjdk-amd64/jre/bin
grep
will return the name of the script / file that is setting the $PATH.