user5813538
user5813538

Reputation:

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

Upvotes: 3

Views: 402

Answers (2)

mpez0
mpez0

Reputation: 2883

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.

Upvotes: 2

chepner
chepner

Reputation: 531155

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.

Upvotes: 5

Related Questions