17

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

4 Answers 4

29

Try which ls to discover full path to ls command

1
10

The command

type name

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

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

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

4

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.

2
  • 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, 2011 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, 2017 at 18:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .