There's a few things you can try:
bash -v to see what lines are being read during shell startup
bash -x to see what commands are being run during shell startup
- run with only one startup file
-v option makes
bash print each line from every script file it reads as it reads it.
Start by running
bash -i -v >bash-i.out 2>&1
wait 5-10 seconds, then press Ctrl+C.
This will give you a single file called
bash-i.out that is like all your startup files merged (or concatenated) together.
less to open the file and search for the alias using
Now, compare where that alias appears in relation to other lines in the file. For example, on most systems,
/etc/bash.bashrc has a comment at the top that says
~/.bashrc has one too.
If it's above the top of your
~/.bashrc, then it's probably a startup file in
/etc that's defining the alias, otherwise it's in your
~/.bashrc or a file it's including via
. (dot command).
If that doesn't show the alias, try
bash -l -v >bash-l.out 2>&1
That tells bash to be a login shell, which reads some different startup files, for example
~/.bash_profile instead of
bash -v doesn't give you a definite answer, try running
bash -x, which prints the commands the shell is running, rather than the lines your shell is reading.
The method is basically the same as the above except change
-x. (You can use both together if necessary.)
Run with only one startup file
bash -i --rcfile="$HOME/.bashrc"
and see if you have the alias.
Try the same with
rcfile set to
/etc/bash.bashrc if your system has it.
bash -l --rcfile="$HOME/.bash_profile"
and do the same with every bash startup file that has
profile in its name, e.g. change
Whichever way makes the alias appear tells you the file you should start looking at.