Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between alias rm and /bin/rm

Tags:

shell

What is the difference between using /bin/rm abc.txt and the times when sometimes you have to alias rm which is then performed with rm abc.txt

like image 227
yan Avatar asked Jul 04 '14 12:07

yan


1 Answers

/bin/rm will always refer to the binary rm command on your system. If you just write rm abc.txt one of these may happen:

  • Your shell implements rm directly as a builtin function or there is a shell function called rm (no external command is run).

  • rm has previously been aliased (with alias rm=<substituted-command>) to mean something different. Usually the aliased command is similar in function but it does not have to be.

  • If none of the above is applicable, the shell looks up the external command in /bin and runs it.

You can use alias to see all defined aliases. Also check out the command -V shell builtin which can tell you if a given command is an external command, shell function, builtin or special builtin.

like image 68
jforberg Avatar answered Sep 22 '22 01:09

jforberg