which (command)

From Wikipedia, the free encyclopedia
  (Redirected from Which (Unix))
Jump to navigation Jump to search
Developer(s)Carlo Wood
Stable release
2.21 / March 20, 2015; 6 years ago (2015-03-20)
Operating systemUnix, Unix-like, Microsoft Windows[1]
LicenseGNU GPL v3
Developer(s)Daniel Papasian
Operating systemFreeBSD
Developer(s)Trane Francks
Stable release
2.1[2] / March 20, 2002; 19 years ago (2002-03-20)
Operating systemFreeDOS
LicenseGNU GPL v2
WebsiteTrane's World: Reinvented
Operating systemAROS Research Operating System
LicenseAROS Public License (APL) Version 1.1 (based on the MPL)[3]

In computing, which is a command for various operating systems used to identify the location of executables. The command is available in Unix and Unix-like systems, the AROS shell,[4] for FreeDOS[5] and for Microsoft Windows.[1] The functionality of the which command is similar to some implementations of the type command. POSIX specifies a command named command that also covers this functionality.[6]


Unix, Unix-like[edit]

The command takes one or more arguments; for each of these arguments, it prints the full path of the executable to stdout that would have been executed if this argument had been entered into the shell. It does this by searching for an executable or script in the directories listed in the environment variable PATH.[7] The which command is part of most Unix-like computers. It is also part of the C Shell.[6]

Carlo Wood developed the GNU implementation used in most Linux-based operating systems.[8]

A which command first appeared in 3BSD.[9]

On FreeBSD, the which utility was originally written in Perl by Wolfram Schneider. The current version of which was rewritten by Daniel Papasian using the C programming language.[10]

Microsoft Windows, MS-DOS, FreeDOS[edit]

The command is available as a separate package for Microsoft Windows as part of the GnuWin32 project[1] and the UnxUtils collection of native Win32 ports of common GNU Unix-like utilities.[11] Windows also includes the similar where.exe command.

The same functionality is available in MS-DOS, but not Windows, as the built-in TRUENAME command.

In PowerShell, the functionality is provided by the Get-Command Cmdlet.[12]

The FreeDOS version was developed by Trane Francks.[13]

AmigaOS compatible[edit]

The command is used to find and print the location of a specific program.[14]


  • FILE – Specifies the command to search for
  • NORES – Resident programs are not included in the search
  • RES – Only resident programs are considered
  • ALL – Will find all locations of the FILE which may cause the printing of the same location several times


  1. ^ a b c which for Windows from the GnuWin32 project
  2. ^ http://www2.gol.com/users/trane/Tranes_World__Reinvented/Programming.html
  3. ^ http://aros.sourceforge.net/license.html
  4. ^ http://aros.sourceforge.net/documentation/users/shell/index.php
  5. ^ http://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/distributions/1.2/repos/pkg-html/group-util.html
  6. ^ a b "Command", The Open group base specification, Issue 7, IEEE std 1003.1-2008
  7. ^ which man page
  8. ^ which(1) – Linux User Commands Manual
  9. ^ which(1) – OpenBSD General Commands Manual
  10. ^ which(1) – FreeBSD General Commands Manual
  11. ^ http://unxutils.sourceforge.net/
  12. ^ https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/get-command?view=powershell-3.0
  13. ^ http://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/distributions/1.2/repos/pkg-html/which.html
  14. ^ http://aros.sourceforge.net/documentation/users/shell/which.php

External links[edit]