Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to find where PATH was set?

When I echo $PATH in UNIX I get this:

   /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/apache-maven/apache-maven-3.3.9/apache-maven-3.3.9/bin

Is there a way to find where

/usr/local/apache-maven/apache-maven-3.3.9/apache-maven-3.3.9/bin

was set? I don't remember setting that.

I checked .profile, .bashrc, and .bash_profile and didn't see any PATH declarations in any of them. So how do I find where someone put it?

EDIT: relevant output of "bash -x -l"

+ '[' -x /usr/libexec/path_helper ']'
++ /usr/libexec/path_helper -s
+ eval 'PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/apache-maven/apache-maven-3.3.9/apache-maven-3.3.9/bin:/Applications/dev/Apache-Derby/db-derby-10.12.1.1-bin/bin";' export 'PATH;'
++ PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/apache-maven/apache-maven-3.3.9/apache-maven-3.3.9/bin:/Applications/dev/Apache-Derby/db-derby-10.12.1.1-bin/bin
++ export PATH

2 Answers

Start your shell with the -x option; the output will show each command that is executed, which includes the source/. commands that will show you which files are sourced. You'll be able to identify file contains the assignment to PATH of interest.

like image 121
chepner Avatar answered Dec 17 '25 12:12

chepner


man bash lists

  • /etc/profile
  • /etc/bash.bashrc
  • ~/.bash_profile
  • ~/.bashrc

As the files it reads on startup. PATH will be modified in one of those, in a file referenced in one of those (or referenced in a file referenced...), or will be set for the login process before your shell is started.

like image 20
mpez0 Avatar answered Dec 17 '25 11:12

mpez0



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!