Which scripts modify the path envirorment variable?

Which scripts modify the path environment variable?
What methods can I use to determine which scripts modify the path environment variable?

Asked By: Lead Vaxeral

||

Just grep for "PATH" on the script of interest. Normal bash additions to PATH occur in .profile. Project specific modifications can be in any file which will be sourced. Different desktop environments which may pop up a terminal without having it run the .profile have caused some to add PATH mods to .bashrc, but that leads to possible duplicates or a different PATH for non-interactive use.

Answered By: ubfan1

Your ~/.bashrc is where YOU can modify PATH, which is a colon-separated list of directories that bash searches for executables.

To add a directory to the beginning of PATH (so it will be searched first), do: export PATH="/opt/somewhere/bin:$PATH". To add it to the end of PATH, do: export PATH="$PATH:/opt/somewhere/bin".

When dealing with "colon-separated" lists (PATH is one example) I use Stephen Collyer’s bash_path_funcs, described in Linux Journal way back in 2000:

https://www.linuxjournal.com/article/3645
https://www.linuxjournal.com/article/3768
https://www.linuxjournal.com/article/3935

The addpath function adds an entry to a path only if it is not there in the first place. delpath -n deletes all non-existent directories from a path. listpath lists a path.

You can get the pathfunc.tgz file from https://web.archive.org/web/20061210054813/http://www.netspinner.co.uk:80/Downloads/pathfunc.tgz

Answered By: waltinator
Categories: Answers Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.