Which (command)

Last updated
which
Developer(s) Carlo Wood, Daniel Papasian, Trane Francks
Stable release
2.21 [1]   OOjs UI icon edit-ltr-progressive.svg / 20 March 2015;9 years ago (20 March 2015)
Operating system Unix, Unix-like, Microsoft Windows, FreeBSD, FreeDOS, AROS Research Operating System [2]
Type Command
License coreutils: GNU GPL v3, BusyBox: BSD, FreeDOS: GNU GPLv2, AROS: AROS Public License (APL) Version 1.1 (based on the MPL) [3]
WebsiteGNU: gnu.org/software/which/ , FreeDOS:Trane's World: Reinvented, AROS: aros.sourceforge.net

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. [2] 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]

Contents

Implementations

Unix, Unix-like, Multics

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. The which command is part of most Unix-like computers. It is also part of the C Shell. [6]

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

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

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. [9]

Multics uses the command where abbreviated as wh.

Microsoft Windows, MS-DOS, FreeDOS

The command is available as a separate package for Microsoft Windows as part of the GnuWin32 project [2] and the UnxUtils collection of native Win32 ports of common GNU Unix-like utilities. [10] 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. [11]

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

AmigaOS compatible

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

Inputs:

Related Research Articles

uniq is a utility command on Unix, Plan 9, Inferno, and Unix-like operating systems which, when fed a text file or standard input, outputs the text with adjacent identical lines collapsed to one, unique line of text.

ls Command to list files and directories in Unix and Unix-like operating systems

In computing, ls is a command to list computer files and directories in Unix and Unix-like operating systems. It is specified by POSIX and the Single UNIX Specification.

pwd Directory information command on various operating systems

In Unix-like and some other operating systems, the pwd command writes the full pathname of the current working directory to the standard output.

In the Unix operating system, shar is an archive format created with the Unix shar utility. A shar file is a type of self-extracting archive, because it is a valid shell script, and executing it will recreate the files. To extract the files, only the standard Unix Bourne shell sh is usually required.

basename is a standard computer program on Unix and Unix-like operating systems. When basename is given a pathname, it will delete any prefix up to the last slash ('/') character and return the result. basename is described in the Single UNIX Specification and is primarily used in shell scripts.

uname Standard UNIX utility that prints name and other details about the machine

uname is a computer program in Unix and Unix-like computer operating systems that prints the name, version and other details about the current machine and the operating system running on it.

chown Command used on Unix-like systems to change the owner of a file

The command chown, an abbreviation of change owner, is used on Unix and Unix-like operating systems to change the owner of file system files and directories. Unprivileged (regular) users who wish to change the group membership of a file that they own may use chgrp.

In computing, touch is a command used to update the access date and/or modification date of a computer file or directory. It is included in Unix and Unix-like operating systems, TSC's FLEX, Digital Research/Novell DR DOS, the AROS shell, the Microware OS-9 shell, and ReactOS. The command is also available for FreeDOS and Microsoft Windows.

The Unix command su, which stands for 'substitute user', is used by a computer user to execute commands with the privileges of another user account. When executed it invokes a shell without changing the current working directory or the user environment.

join is a command in Unix and Unix-like operating systems that merges the lines of two sorted text files based on the presence of a common field. It is similar to the join operator used in relational databases but operating on text files.

tr (Unix) Unix text formatting utility

tr is a command in Unix, Plan 9, Inferno, and Unix-like operating systems. It is an abbreviation of translate or transliterate, indicating its operation of replacing or removing specific characters in its input data set.

wc (Unix) Unix command utility

wc is a command in Unix, Plan 9, Inferno, and Unix-like operating systems. The program reads either standard input or a list of computer files and generates one or more of the following statistics: newline count, word count, and byte count. If a list of files is provided, both individual file and total statistics follow.

cksum Unix command

cksum is a command in Unix and Unix-like operating systems that generates a checksum value for a file or stream of data. The cksum command reads each file given in its arguments, or standard input if no arguments are provided, and outputs the file's 32-bit cyclic redundancy check (CRC) checksum and byte count. The CRC output by cksum is different from the CRC-32 used in zip, PNG and zlib.

In computing, cmp is a command-line utility on Unix and Unix-like operating systems that compares two files of any type and writes the results to the standard output. By default, cmp is silent if the files are the same; if they differ, the byte and line number at which the first difference occurred is reported. The command is also available in the OS-9 shell.

rm (Unix) Unix command utility

rm is a basic command on Unix and Unix-like operating systems used to remove objects such as computer files, directories and symbolic links from file systems and also special files such as device nodes, pipes and sockets, similar to the del command in MS-DOS, OS/2, and Microsoft Windows. The command is also available in the EFI shell.

tail is a program available on Unix, Unix-like systems, FreeDOS and MSX-DOS used to display the tail end of a text file or piped data.

In computing, tee is a command in command-line interpreters (shells) using standard streams which reads standard input and writes it to both standard output and one or more files, effectively duplicating its input. It is primarily used in conjunction with pipes and filters. The command is named after the T-splitter used in plumbing.

yes (Unix) Unix command

yes is a command on Unix and Unix-like operating systems, which outputs an affirmative response, or a user-defined string of text, continuously until killed.

In computing, sleep is a command in Unix, Unix-like and other operating systems that suspends program execution for a specified time.

whoami Command on various operating systems

In computing, whoami is a command found on most Unix-like operating systems, Intel iRMX 86, every Microsoft Windows operating system since Windows Server 2003, and on ReactOS. It is a concatenation of the words "Who am I?" and prints the effective username of the current user when invoked.

References

  1. "which".
  2. 1 2 3 which for Windows from the GnuWin32 project
  3. "AROS Public License version 1.1".
  4. "AROS Research Operating System".
  5. "FreeDOS 1.2 Updates Group - Utilities". Ibiblio.org. Retrieved 2022-09-08.
  6. 1 2 "Command", The Open group base specification, Issue 7, IEEE std 1003.1-2008
  7. which(1)    OpenBSD General Commands Manual
  8. which(1)    Linux User Commands Manual
  9. which(1)    FreeBSD General Commands Manual
  10. "Native Win32 ports of some GNU utilities". Unxutils.sourceforge.net. Retrieved 2022-09-08.
  11. "Get-Command (Microsoft.PowerShell.Core) - PowerShell".
  12. "FreeDOS 1.2 Updates Package - which (Unix-like)". Ibiblio.org. 2002-03-20. Retrieved 2022-09-08.
  13. "AROS Research Operating System".