Score:0

where is the source code for the which command?

au flag
j0h

I looked around in coreutils, and did sudo apt-cache search which I also looked at the manpages of which, I didn't find it.

I'd like to add an argument for listing dependencies to the executable, I think it would be useful.

Score:10
hr flag

At least on my Ubuntu 22.04, /usr/bin/which is provided by the debianutils package:

$ update-alternatives --list which
/usr/bin/which.debianutils
$ 
$ dpkg -S /usr/bin/which.debianutils 
debianutils: /usr/bin/which.debianutils

It's a shell script - so no need to download the source:

$ file /usr/bin/which.debianutils 
/usr/bin/which.debianutils: POSIX shell script, ASCII text executable
Score:1
gl flag

On Ubuntu 18.04.6 LTS /usr/bin/which is in the path for a normal (non-root) user:

$ which which
/usr/bin/which

And the above is a symbolic link:

$ file /usr/bin/which
/usr/bin/which: symbolic link to /bin/which

And the target is a shell script:

$ file /bin/which
/bin/which: POSIX shell script, ASCII text executable

And the shell script is provided by debianutils

$ dpkg -S /bin/which
debianutils: /bin/which

The above answer is a variation of the answer from steeldriver, showing Ubuntu 18.04 is slightly different from Ubuntu 22.04.

Under Ubuntu 18.04 update-alternatives is reporting an error for which:

$ update-alternatives --list which
update-alternatives: error: no alternatives for which
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.