OnWorks Linux and Windows Online WorkStations

Logo

Free Hosting Online for WorkStations

< Previous | Contents | Next >

which – Display An Executable's Location

Sometimes there is more than one version of an executable program installed on a sys- tem. While this is not very common on desktop systems, it's not unusual on large servers. To determine the exact location of a given executable, the which command is used:


[me@linuxbox ~]$ which ls

/bin/ls

[me@linuxbox ~]$ which ls

/bin/ls


which only works for executable programs, not builtins nor aliases that are substitutes for actual executable programs. When we try to use which on a shell builtin, for exam- ple, cd, we either get no response or an error message:


[me@linuxbox ~]$ which cd

/usr/bin/which: no cd in (/opt/jre1.6.0_03/bin:/usr/lib/qt- 3.3/bin:/usr/kerberos/bin:/opt/jre1.6.0_03/bin:/usr/lib/ccache:/usr/l ocal/bin:/usr/bin:/bin:/home/me/bin)

[me@linuxbox ~]$ which cd

/usr/bin/which: no cd in (/opt/jre1.6.0_03/bin:/usr/lib/qt- 3.3/bin:/usr/kerberos/bin:/opt/jre1.6.0_03/bin:/usr/lib/ccache:/usr/l ocal/bin:/usr/bin:/bin:/home/me/bin)


which is a fancy way of saying “command not found.”


Top OS Cloud Computing at OnWorks: