whereis
command tells you where the binary and all documentations are located of a command. But not all commands have some binary that is invoked whenever they are executed. Some commands are shell built-in. Since Ubuntu uses bash as its default shell, these Bash Builtins are present.
The easiest way to determine whether a command is an alias or invokes some binary or is a command provided by the shell, is using type
(which itself is also a shell built-in command) with -a
option.
For example, if you use
whereis cd
You'll observe that there is no output which may convince you that cd
is some magical thing which isn't present in /usr/bin. But cd
is a shell built-in command. And if you run
type -a cd
You'll get
cd is a shell builtin
If you try it yourself, you'll find that rm
does have a binary in /bin.
But there are some exceptions. echo
is the example.
If you run
type -a echo
You'll get
echo is a shell builtin
echo is /bin/echo
That means there is both an echo
shell built-in command and an external command in /bin/echo. The reason is described in Eliah Kagan's answer and muru's answer.
ls
is another exception. By default ls
is an alias to ls --color=auto
as well. The output of type -a ls
will look like:
ls is aliased to `ls --color=auto'
ls is /bin/ls
This alias is defined in ~/.bashrc. If this alias is "unaliased", ls
would invoke the binary located in /bin.
/usr/bin
isn't only UNIX). – terdon Sep 18 '19 at 11:11ls
is, I'd usewhereis ls
and it tells be where the binary is located, plus manual (reference) page is too. – guiverc Sep 18 '19 at 11:14whereis
searches your $PATH for binaries (programs) that meet your request; if the "file path" you're asking about is the environment variable $PATH I missed it (I'm not sure what you really are after, as terdon already alluded to) – guiverc Sep 18 '19 at 11:21rm
will not be the answer. – terdon Sep 18 '19 at 11:52