Is there a shell command for outputing absolute path for specified program? I'd like to know where executable binary file is.
4 Answers
Try which ls
to discover full path to ls
command
-
1
The command
type name
will give you every information about name
, if executable (returning also the path), shell alias, shell function, shell builtin.
-
1
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 aPATH
search,mlocate
would return many unrelated results (unrelated to what OP asked: "absolute path for specified program")– enzotibOct 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.– terdonMar 4, 2017 at 18:14