There's a few things you can try:
- use
bash -v to see what lines are being read during shell startup
- use
bash -x to see what commands are being run during shell startup
- run with only one startup file
bash -v
The -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.
Then use less to open the file and search for the alias using /aliasname.
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 /etc/bash.bashrc and ~/.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 source or . (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 /etc/profile and ~/.bash_profile instead of /etc/bash.bashrc and ~/.bashrc.
bash -x
If 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 -v to -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.
Then try
bash -l --rcfile="$HOME/.bash_profile"
and do the same with every bash startup file that has profile in its name, e.g. change $HOME/.bash_profile to /etc/profile.
Whichever way makes the alias appear tells you the file you should start looking at.
set -xas suggested at the top of your and see if that narrows it down for you.set -xat the top of/etc/bash_profileor/etc/bashrc. Why not just runbash -i -xorbash -l -x?