Where have I set my bash PATH?

I want to remove ~/bin from my PATH.  I set it up months ago when Linux (Ubuntu) was very new to me, but I don’t know how I added it…

Nothing shows up when I search all the files listed below.
Where else could it be being set?  It is being pre-pended after $HOME/.profile prefixes PATH with $HOME/bin

If it makes any difference, I get the same PATH from both the command-prompt and a running script.

#!/bin/bash
{
  echo "first dir of PATH is: '${PATH%%:*}'"
  shopt -s nullglob
  cat 
    /etc/profile 
    /etc/bash.bashrc 
    /etc/profile.d/*.sh 
    $HOME/.bashrc 
    $HOME/.bash_aliases 
    /etc/bash_completion 
    $HOME/.bash_completion* 
    $HOME/.profile 
    $HOME/.profile_zap 
    $HOME/.bash_profile* 
    $HOME/.bash_login* 
  | sed -rne '/~/bin/p'
}

Output is:

first dir of PATH is: '~/bin'

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

You might want to trace the full environment load on login. Just an idea.

Since /etc/profile is the first file sourced, you can add to it at the very top a:

set -x
exec 2> /tmp/debug.log

Then open a new terminal and do a bash -l; after that go to the original terminal and remove the lines added (you want to have a working environment, don’t you?).

You should end with a full trace of all the steps of the loading_the_bash_environment at /tmp/debug.log. It will be a loooong file.

With that you must be able to locate where the “~/bin” gets into your PATH

I’d look first for a grep of all the files sourced. From your post I bet that the ~/bin in the path is set in a different file of those you’ve listed.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x