0

I used a program that set system setting and I can't find where my PATH environment variable was set, it's not set in:

  • .bashrc
  • .bash_profile
  • .profile
  • etc/paths

I have been trying to use a grep command:

grep -rl "PATH=" /

but the command is taking forever.

Does anyone have any suggestion on searching for where my PATH was assigned?

HelloWorld
  • 10,529
  • 10
  • 31
  • 50

1 Answers1

2

Run the following command:

PS4='+ $BASH_SOURCE:$LINENO:' BASH_XTRACEFD=7 bash -xlic "" 7>trace.out

Now, look through the file trace.out. It will show you everytime PATH was modified along with the file name and line number which caused the change.

Example

$ grep PATH trace.out
+ /etc/profile:7:PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
+ /etc/profile:9:export PATH

This tells you that line 7 of the file /etc/profile set the PATH.

How it works

The short story is that this starts up a bash login session with tracing turned on. For a longer explanation, see here.

Community
  • 1
  • 1
John1024
  • 109,961
  • 14
  • 137
  • 171