source: general/sysutils/which.xml@ 25357c89

initial-import reorg
Last change on this file since 25357c89 was f45b1953, checked in by Mark Hymers <markh@…>, 22 years ago

Initial revision

git-svn-id: svn://svn.linuxfromscratch.org/BLFS/trunk/BOOK@3 af4574ff-66df-0310-9fd7-8a98e5e911e0

  • Property mode set to 100644
File size: 1.5 KB
Line 
1<sect1 id="which" xreflabel="which-&which-version;">
2<?dbhtml filename="which.html" dir="general"?>
3<title>The "which" program / script</title>
4
5<para>The presence / absence of the which program in the main LFS book
6is probably one of the most contentious issues we have on the mailing
7lists. It has resulted in at least one flame war in the recent past.
8To hopefully put an end to this once and for all, we here present the
9various options for equipping your system with "which".</para>
10
11<para>The first option is simply to use a bash alias:</para>
12<screen>alias which='type -p'</screen>
13<para>This command can be put in your
14<filename>~/.bash_profile</filename> or <filename>~/.bashrc</filename>
15file in order to be set up each time you log in (see man bash for more
16information on the bash login files). This will not always work
17however, for example it will fail when a program needs to use "which"
18but
19doesn't spawn a shell.</para>
20
21<para>The second option is to create a simple script:</para>
22<para><screen><userinput>cat &gt; /usr/bin/which &lt;&lt;
23"EOF"</userinput>
24#!/bin/bash
25type -p "$@"
26<userinput>EOF
27chmod 755 /usr/bin/which
28chown root.root /usr/bin/which</userinput></screen></para>
29<para>This should generally work OK and is probably the easiest solution
30for boxes which don't need a good user environment to work in.</para>
31
32<para>The third option is to install the actual program
33<emphasis>which</emphasis>.</para>
34
35&which-intro;
36&which-inst;
37&which-desc;
38
39</sect1>
40
Note: See TracBrowser for help on using the repository browser.