Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

How can I know if an alias I make (in .bash_aliases) is not replacing an actual command by same name? I don't want to do such things by accident.

(I looked in "Questions that may already have your answer" and "Similar Questions" but did not see matches)

I'm asking because I feel there is no warning given by the system (Ubuntu 13.10).

share|improve this question

marked as duplicate by Eric Carvalho, Pilot6, muru, waltinator, 2707974 Oct 1 '15 at 9:22

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

up vote 9 down vote accepted

You can use type in terminal for this.

Say you have a command rm as alias rm -i. If you check,

type rm

you will get,

rm is aliased to `rm -i'

If you do not have any alias for rm you will get,

rm is /bin/rm
share|improve this answer
This doesn't help with commands like locate which seems to me to be an alias for a more powerful find command, but I could be wrong. I'm actually on a quest to find the difference – MishaP Oct 7 '14 at 23:44
@MishaP type locate returns "locate is /usr/bin/locate". See manpage of locate for more. I did not understood why you think it an alias. – souravc Oct 8 '14 at 2:57
you're right, it's not. I'm used to using find, so when I saw someone using locate I just assumed it was some system default alias like ll. When I have a little extra time I'll dig in to try to find the difference. Hopefully it's not just (essentially) duplicate commands. That would really suck.... – MishaP Nov 6 '14 at 19:03

Warning: this method requires you to actually run the command, unlike the other answers that "report" on the shell state. You can never be sure till execution-time, can you?

In your shell, type

set -x

You will see + ... lines as the shell executes. For example, when I run ls, which is usually aliased to ls --color=auto on Ubuntu, I get this:

$ ls ~
+ ls --color=auto /home/rctay
bin         ext      Music     shared     tmp-www                tmux-client-32280.log

To turn it off, run set +x.

share|improve this answer

Before defining the alias for some command, call it fn, run type on the command name:

type fn

If there is no command of that name, type will return not found.

After you have defined an alias, you can use locate to check for possible conflicts:

locate '*bin/fn'

This looks anywhere on the system for a command named fn in a directory whose name would indicate that it is an executable. Note that this is not the same as type because locate will look in bin directories that may not be on your default path.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.