I used to run the following commands to find out if a command exists (besides using Bash auto-completion if it's executable in PATH) and what kind of the command is:
And I am not kidding you, I manually typed
However, the better ways can be:
Note that
$ type which which is /usr/bin/which $ file /usr/bin/which /usr/bin/which: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.9, stripped
And I am not kidding you, I manually typed
/usr/bin/which
in the second command to find out the file type. file
requires a full path. I feel little embarrassed. :) But, it's nothing wrong with it.However, the better ways can be:
$ file `type -p which` $ file `which which`
Note that
type
is a Bash shell builtin command (can differ from your environment), which
is a normal program. You can also use locate
for file
'd a list of matched files if you only have partial filename. All three commands can accept a number of filenames.