Bash – How to Find a Rogue Alias Declaration

aliasbashbashrc

I'm trying to find where a specific alias has been declared. I've searched all the usual places I know to look for aliases:

  • ~/.bashrc
  • ~/.bash_profile
  • /etc/bashrc
  • /etc/profile

With no luck.

I know it's an alias because when I do which COMMAND, I get:

alias COMMAND='/path/to/command'
    /path/to/command

Is there a way to find what file declares an alias only knowing the alias name?

Best Answer

I would look in /etc/profile.d/ for the offending alias.

You could also do the following to find it:

grep -r '^alias COMMAND' /etc

This will recursively grep through files looking for a line beginning with alias COMMAND.

If all else fails, put this at the end of your ~/.bashrc

unalias COMMAND
Related Question