Which

From Linuxintro
Revision as of 09:15, 11 June 2011 by imported>ThorstenStaerk
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The command which is an easy way to find out where an executable program comes from. As an example:

 tweedleburg:~ # which ls
 /bin/ls
 tweedleburg:~ # which which
 /usr/bin/which
 tweedleburg:~ # which alias
 which: no alias in (/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/opt/kde3/bin:/usr/lib64/jvm/jre/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin:/usr/NX/bin:/usr/lib/qt3/bin)

in the case of alias we find out it is a shell builtin. You can find this out using the command type:

tweedleburg:~ # type alias
alias is a shell builtin
tweedleburg:~ # type which
which is hashed (/usr/bin/which)
tweedleburg:~ # type ls
ls is aliased to `ls $LS_OPTIONS'

See also