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.

  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'
  • Try grepping for PATH instead. If still no luck, check all files for anything that is being sourced.
    – jw013
    Aug 5, 2011 at 16:06
  • Did you check your ~/.bashrc and ~/.profile for it? If not have a look at the /etc/profile. I think you'll find it in one of these places.
    – nikhil
    Aug 5, 2011 at 16:49
  • Thanks everyone... all suggestions have been helpful... it was in ~/.gnomerc...
    – Peter.O
    Aug 5, 2011 at 17:27

1 Answer 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.

  • @hmontoliu.. I've had a couple of problems with this.. First, nothing is going to the log, but I am getting a lot of output in the terminal (konsole) ... The first reference to ~/bin shows it already in the path, but I can see no hint of where it came from.. It is, at this point, already followed by the $HOME/bin from $HOME/.profile (I'm sure it's from there, as I've used a special extra directory for this test) .... Howerver, I've managed to find it empirically, by searching all my text files.. It comes from ~/.gnomerc.. and I need to re-log in to cause it to change. ??!! ..
    – Peter.O
    Aug 5, 2011 at 17:18
  • Are you sure that you've pasted the lines on top of /etc/profile and that you're executing it with a plain bash -l? It must send the debugging (-x) which goes to stderr to /tmp/debug.log; indeed I've just tested this and works as I've expected
    – hmontoliu
    Aug 5, 2011 at 17:22
  • I'll try it again (again)... This log analysis is definitely the way to go (when all else fails :) and this is a good opportunity for me to get a better understand of it...
    – Peter.O
    Aug 5, 2011 at 17:30
  • ... I'll have to put this log issue into the too hard basket for now.. It still didn't output to the logfile, but I got hundreds of lines in the terminal.. but that's okay.. It has been a good intro to the debug log.. and I've certainly got a much better feel of the config files... thanks...
    – Peter.O
    Aug 5, 2011 at 18:15
  • 3
    I had to replace set with exec in the second line, then it worked perfectly for me :)
    – thomasa88
    Oct 13, 2012 at 15:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .