How will be interpreted a command

Tips Shell
September 27, 2006 | COMMENTS

You probably have set some personnal alias or function on your box. Most common is probably dir, ls, ll... If you forgot how you define your alias or function, the easiest way for get back the definition isn't to read your numerous .bashrc but using some bash built-in command : type or command.

type: usage: type [-afptP] name [name ...]
command: usage: command [-pVv] command [arg ...]

Command is generally used for running command with arguments ignoring any shell function named command. Instead of Type that describe a command, for each name, indicate how it would be interpreted if used as a command name. But both can be used, here is some examples :

[root@host ~]# alias -p
alias cp='cp -i'
alias mv='mv -i'
alias rm='rm -i'
[root@host ~]# command -v rm
alias rm='rm -i'
[root@host ~]# command -V rm
rm is aliased to `rm -i'
[root@host ~]# type rm
rm is aliased to `rm -i'