16

Is there a shell command for outputing absolute path for specified program? I'd like to know where executable binary file is.

26

Try which ls to discover full path to ls command

9

The command

type name

will give you every information about name, if executable (returning also the path), shell alias, shell function, shell builtin.

  • 1
    And type -P to search specifically for binaries – wjandrea Nov 17 '18 at 15:55
5

whereis -b yourBinary will output the location of a program.

3

All of the above, with some caveats:

whereis -- searches for matches (by default) on some pre-set directories. The list is available on 'man whereis', and can be passed as a parameter

which -- searches for executable files in the current environment (in other words, executables that can be found in the directories listed in the environment variable PATH

(bash) type -- if 'name' is an alias, it lists the alias definition, but not necessarily the path of any executables in the definition.

Another option, more generic, is mlocate.

  • 1
    type -P always performs a PATH search, mlocate would return many unrelated results (unrelated to what OP asked: "absolute path for specified program") – enzotib Oct 5 '11 at 12:13
  • type isn't bash; it's POSIX: pubs.opengroup.org/onlinepubs/009604499/utilities/type.html. It should be available on all POSIX-compliant shells. – terdon Mar 4 '17 at 18:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.