Most shells have some provision for aliases. Aliases can assign default behavior to a command (for example "rm" is often aliased to "rm -i") or can be used to create new commands (a typical example is "ll" aliased to be "ls -l").
Aliases are expanded before looking in $PATH. Depending upon your Bash settings, a "which" for a over-ride alias like "rm" may show you the commands found in $PATH also:
bash-2.01$ which rm
rm: aliased to rm -i
# a different machine
bash-2.05b$ which rm
alias rm='rm -i'
/bin/rm
To get the second behavior, 'which' itself was aliased :
bash-2.05b$ which which
alias which='alias | /usr/bin/which --tty-only --read-alias
--show-dot --show-tilde'
/usr/bin/which
Aliases are NOT normally expanded in non-interactive shells, which means that if you use "rm" in a script, you won't get the alias - unless you want to, in which case you do "shopt -s expand_aliases" before calling it. If you want to be safe, use /bin/rm instead, which can't ever be confused with an alias.
There are other confusing rules for alias expansion; even the man page admits the potential for gross misunderstanding and follows that confession with this:
For almost every purpose, aliases are superseded by shell functions.
You might construe that as an apology of sorts, but while the maintainers of Bash might fondly hope (and have excellent reasons for hoping) for that to be true, in fact and in common practise, aliases continue to be used regularly and I have little doubt that will remain true for a long, long time.
More Articles by Tony Lawrence - Find me on Google+

Have you tried Searching this site?
Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates
This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more. We appreciate comments and article submissions.
Many of the products and books I review are things I purchased for my own use. Some were given to me specifically for the purpose of reviewing them. I resell or can earn commissions from the sale of some of these items. Links within these pages may be affiliate links that pay me for referring you to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain. I also may own stock in companies mentioned here. If you have any question, please do feel free to contact me.
Specific links that take you to pages that allow you to purchase the item I reviewed are very likely to pay me a commission. Many of the books I review were given to me by the publishers specifically for the purpose of writing a review. These gifts and referral fees do not affect my opinions; I often give bad reviews anyway.
We use Google third-party advertising companies to serve ads when you visit our website. These companies may use information (not including your name, address, email address, or telephone number) about your visits to this and other websites in order to provide advertisements about goods and services of interest to you. If you would like more information about this practice and to know your choices about not having this information used by these companies, click here.
Click here to add your comments
Don't miss responses! Subscribe to Comments by RSS or by Email
Click here to add your comments
If you want a picture to show with your comment, go get a Gravatar