[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Where is lsof?

Mikkel L. Ellertson wrote:
Alan Evans wrote:
> On Tue, May 5, 2009 at 5:39 AM, Mike Cloaked wrote:
>> Usually a good way to find where a command is would be to use the "which"
>> command. In this case:
>> [mike gestalt ~]$ which lsof
>> /usr/sbin/lsof
> How is that going to work if /usr/sbin isn't already in your path?
It does work. Try it yourself.

$ which lsof
$ echo $PATH
You'll note that /usr/sbin *is* in your path and the man page for which says:

Which takes one or more arguments. For each of its arguments it prints
      to stdout the full path of the executables that would have been exe-
cuted when this argument had been entered at the shell prompt. It does this by searching for an executable or script in the directories listed
      in the environment variable PATH using the same algorithm as bash(1).

So if you hadn't had /usr/sbin in your PATH, then "which lsof" would have returned nothing - so it isn't useful for this situation...

[sam sam ~]$ echo $PATH
[sam sam ~]$ which lsof
[sam sam ~]$ export PATH=/usr/kerberos/bin:/usr/bin:/bin:/sbin
[sam sam ~]$ which lsof
/usr/bin/which: no lsof in (/usr/kerberos/bin:/usr/bin:/bin:/sbin)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]