The presence or absence of the which program in the main LFS book is probably one of the most contentious issues we have on the mailing lists. It has resulted in at least one flame war in the past. To hopefully put an end to this once and for all, we here present two of the options for equipping your system with "which". The question of which "which" is for you to decide.
The first option is to install the actual GNU program which.
Download (HTTP): http://www.xs4all.nl/~carlo17/which/which-2.16.tar.gz
Download (FTP): ftp://ftp.gnu.org/gnu/which/which-2.16.tar.gz
Download size: 123 KB
Estimated Disk space required: 940 KB
Estimated build time: 0.03 SBU
Install which by running the following commands:
./configure --prefix=/usr &&
make &&
make install
The which package contains which.
The second option (for those who don't want to install the program) is to create a simple script:
cat > /usr/bin/which << "EOF" #!/bin/bash type -pa "$@" | head -n 1 ; exit ${PIPESTATUS[0]} EOF chmod 755 /usr/bin/which chown root:root /usr/bin/which
This should work OK and is probably the easiest solution for most cases, but is not the most comprehensive implementation.