Imported Upstream version 4.88
[platform/upstream/lsof.git] / lsof.8
1 .ds VN 4.88
2 .TH LSOF 8 Revision-\*(VN
3 .if !\n()P .nr )P 1v
4 .SH NAME
5 lsof \- list open files
6 .SH SYNOPSIS
7 .B lsof
8 [
9 .B \-?abChKlnNOPRtUvVX
10 ] [
11 .BI -A " A"
12 ] [
13 .BI \-c " c"
14 ] [
15 .BI +c " c"
16 ] [
17 .BI +|\-d " d"
18 ] [
19 .BI +|\-D " D"
20 ] [
21 .BI +|\-e " s"
22 ] [
23 .B +|-E
24 ] [
25 .B +|\-f [cfgGn]
26 ] [
27 .BI \-F " [f]"
28 ] [
29 .BI \-g " [s]"
30 ] [
31 .BI \-i " [i]"
32 ] [
33 .BI \-k " k"
34 ] [
35 .BI +|\-L " [l]"
36 ] [
37 .BI +|\-m " m"
38 ] [
39 .B +|\-M
40 ] [
41 .BI \-o " [o]"
42 ] [
43 .BI \-p " s"
44 ] [
45 .BI +|\-r " [t[m<fmt>]]"
46 ] [
47 .BI \-s " [p:s]"
48 ] [
49 .BI \-S " [t]"
50 ] [
51 .BI \-T " [t]"
52 ] [
53 .BI \-u " s"
54 ] [
55 .B +|\-w
56 ] [
57 .BI \-x " [fl]"
58 ] [
59 .BI \-z " [z]"
60 ] [
61 .BI \-Z " [Z]"
62 ] [
63 .B --
64 ] [\fInames\fP]
65 .SH DESCRIPTION
66 .I Lsof
67 revision \*(VN lists on its standard output file information about files
68 opened by processes for the following UNIX dialects:
69 .PP
70 .nf
71         Apple Darwin 9 and Mac OS X 10.[567]
72         FreeBSD 8.[234], 9.0, 10.0 and 11.0 for AMD64-based systems
73         Linux 2.1.72 and above for x86-based systems
74         Solaris 9, 10 and 11
75 .fi
76 .PP
77 (See the
78 .B DISTRIBUTION
79 section of this manual page for information on how to obtain the
80 latest
81 .I lsof
82 revision.)
83 .PP
84 An open file may be a regular file, a directory, a block special file,
85 a character special file, an executing text reference, a library,
86 a stream or a network file (Internet socket, NFS file or UNIX domain socket.)
87 A specific file or all the files in a file system may be selected by path.
88 .PP
89 Instead of a formatted display,
90 .I lsof
91 will produce output that can be parsed by other programs.
92 See the
93 .BR \-F ,
94 option description, and the
95 .B "OUTPUT FOR OTHER PROGRAMS"
96 section for more information.
97 .PP
98 In addition to producing a single output list,
99 .I lsof
100 will run in repeat mode.
101 In repeat mode it will produce output, delay, then repeat the output
102 operation until stopped with an interrupt or quit signal.
103 See the
104 .BI +|\-r " [t[m<fmt>]]"
105 option description for more information.
106 .SH OPTIONS
107 In the absence of any options,
108 .I lsof
109 lists all open files belonging to all active processes.
110 .PP
111 If any list request option is specified, other list requests must be
112 specifically requested \- e.g., if
113 .B \-U
114 is specified for the listing of UNIX socket files, NFS files won't be
115 listed unless
116 .B \-N
117 is also specified;
118 or if a user list is specified with the
119 .B \-u
120 option, UNIX domain socket files, belonging to users not in the list,
121 won't be listed unless the
122 .B \-U
123 option is also specified.
124 .PP
125 Normally list options that are specifically stated are ORed \- i.e.,
126 specifying the
127 .B \-i
128 option without an address and the \fB\-u\fPfoo option produces a
129 listing of all network files OR files belonging to processes owned
130 by user ``foo''.
131 The exceptions are:
132 .TP \w'1)\ 'u
133 1)
134 the `^' (negated) login name or user ID (UID), specified with the
135 .B \-u
136 option;
137 .TP \w'1)\ 'u
138 2)
139 the `^' (negated) process ID (PID), specified with the
140 .B \-p
141 option;
142 .TP \w'1)\ 'u
143 3)
144 the `^' (negated) process group ID (PGID), specified with the
145 .B \-g
146 option;
147 .TP \w'1)\ 'u
148 4)
149 the `^' (negated) command, specified with the
150 .B \-c
151 option;
152 .TP \w'1)\ 'u
153 5)
154 the (`^') negated TCP or UDP protocol state names, specified with the
155 .BI \-s " [p:s]"
156 option.
157 .PP
158 Since they represent exclusions, they are applied without ORing or ANDing
159 and take effect before any other selection criteria are applied.
160 .PP
161 The
162 .B \-a
163 option may be used to AND the selections.
164 For example, specifying
165 .BR \-a ,
166 .BR \-U ,
167 and \fB\-u\fPfoo produces a listing of only UNIX socket files that
168 belong to processes owned by user ``foo''.
169 .PP
170 Caution: the
171 .B \-a
172 option causes all list selection options to be ANDed; it can't
173 be used to cause ANDing of selected pairs of selection options
174 by placing it between them, even though its placement there is
175 acceptable.
176 Wherever
177 .B \-a
178 is placed, it causes the ANDing of all selection options.
179 .PP
180 Items of the same selection set \- command names, file descriptors,
181 network addresses, process identifiers, user identifiers, zone names,
182 security contexts \- are joined in a single ORed set and applied
183 before the result participates in ANDing.
184 Thus, for example, specifying \fB\-i\fP@aaa.bbb, \fB\-i\fP@ccc.ddd,
185 .BR \-a ,
186 and \fB\-u\fPfff,ggg will select the listing of files that belong to
187 either login ``fff'' OR ``ggg'' AND have network connections to either
188 host aaa.bbb OR ccc.ddd.
189 .PP
190 Options may be grouped together following a single prefix -- e.g.,
191 the option set ``\fB\-a \-b \-C\fP'' may be stated as
192 .BR \-abC .
193 However, since values are optional following 
194 .BR +|\-f ,
195 .BR \-F ,
196 .BR \-g ,
197 .BR \-i ,
198 .BR +|\-L ,
199 .BR \-o ,
200 .BR +|\-r ,
201 .BR \-s ,
202 .BR \-S ,
203 .BR \-T ,
204 .B \-x
205 and
206 .BR \-z .
207 when you have no values for them be careful that the
208 following character isn't ambiguous.
209 For example,
210 .B \-Fn
211 might represent the
212 .B \-F
213 and
214 .B \-n
215 options, or it might represent the
216 .B n
217 field identifier character following the
218 .B \-F
219 option.
220 When ambiguity is possible, start a new option with a `-'
221 character \- e.g., ``\fB\-F \-n\fP''.
222 If the next option is a file name, follow the possibly ambiguous
223 option with ``--'' \- e.g., ``\fB\-F -- \fIname\fR''.
224 .PP
225 Either the `+' or the `\-' prefix may be applied to a group of options.
226 Options that don't take on separate meanings for each
227 prefix \- e.g., \fB\-i\fP \- may be grouped under either prefix.
228 Thus, for example, ``+M -i'' may be stated as ``+Mi'' and the group
229 means the same as the separate options.
230 Be careful of prefix grouping when one or more options in the group
231 does take on separate meanings under different prefixes \-
232 e.g., \fB+|\-M\fP; ``-iM'' is not the same request as ``\-i +M''.
233 When in doubt, use separate options with appropriate prefixes.
234 .TP \w'names'u+4
235 .B \-? \-h
236 These two equivalent options select a usage (help) output list.
237 .I Lsof
238 displays a shortened form of this output when it detects an error
239 in the options supplied to it, after it has displayed messages
240 explaining each error.
241 (Escape the `?' character as your shell requires.)
242 .TP \w'names'u+4
243 .B \-a
244 causes list selection options to be ANDed, as described above.
245 .TP \w'names'u+4
246 .BI \-A " A"
247 is available on systems configured for AFS whose AFS
248 kernel code is implemented via dynamic modules.
249 It allows the
250 .I lsof
251 user to specify
252 .I A
253 as an alternate name list file where the kernel addresses of the dynamic
254 modules might be found.
255 See the
256 .I lsof
257 FAQ (The \fBFAQ\fP section gives its location.)
258 for more information about dynamic modules, their
259 symbols, and how they affect
260 .IR lsof .
261 .TP \w'names'u+4
262 .B \-b
263 causes
264 .I lsof
265 to avoid kernel functions that might block \-
266 .IR lstat (2),
267 .IR readlink (2),
268 and
269 .IR stat (2).
270 .IP
271 See the
272 .B "BLOCKS AND TIMEOUTS"
273 and
274 .B "AVOIDING KERNEL BLOCKS"
275 sections for information on using this option.
276 .TP \w'names'u+4
277 .BI \-c " c"
278 selects the listing of files for processes executing the
279 command that begins with the characters of
280 .IR c .
281 Multiple commands may be specified, using multiple
282 .B \-c
283 options.
284 They are joined in a single ORed set before participating in
285 AND option selection.
286 .IP
287 If
288 .I c
289 begins with a `^', then the following characters specify a command
290 name whose processes are to be ignored (excluded.)
291 .IP
292 If
293 .I c
294 begins and ends with a slash ('/'), the characters between the slashes
295 are interpreted as a regular expression.
296 Shell meta\-characters in the regular expression must be quoted to prevent 
297 their interpretation by the shell.
298 The closing slash may be followed by these modifiers:
299 .IP
300 .nf
301         b       the regular expression is a basic one.
302 .br
303         i       ignore the case of letters.
304 .br
305         x       the regular expression is an extended one
306 .br
307                 (default).
308 .fi
309 .IP
310 See the
311 .I lsof
312 FAQ (The \fBFAQ\fP section gives its location.)
313 for more information on basic and extended regular
314 expressions.
315 .IP
316 The simple command specification is tested first.
317 If that test fails, the command regular expression is applied.
318 If the simple command test succeeds, the command regular expression
319 test isn't made.
320 This may result in ``no command found for regex:'' messages
321 when lsof's
322 .B \-V
323 option is specified.
324 .TP \w'names'u+4
325 .BI +c " w"
326 defines the maximum number of initial characters of the name,
327 supplied by the UNIX dialect, of the UNIX command associated with a process
328 to be printed in the COMMAND column.
329 (The
330 .I lsof
331 default is nine.)
332 .IP
333 Note that many UNIX dialects do not supply all command name characters
334 to
335 .I lsof
336 in the files and structures from which
337 .I lsof
338 obtains command name.
339 Often dialects limit the number of characters supplied in those sources.
340 For example, Linux 2.4.27 and Solaris 9 both limit command name length to
341 16 characters.
342 .IP
343 If
344 .I w
345 is zero ('0'), all command characters supplied to
346 .I lsof
347 by the UNIX dialect will be printed.
348 .IP
349 If
350 .I w
351 is less than the length of the column title, ``COMMAND'', it will
352 be raised to that length.
353 .TP \w'names'u+4
354 .B \-C
355 disables the reporting of any path name
356 components from the kernel's name cache.
357 See the
358 .B "KERNEL NAME CACHE"
359 section for more information.
360 .TP \w'names'u+4
361 .BI +d " s"
362 causes
363 .I lsof
364 to search for all open instances of directory
365 .I s
366 and the files and directories it contains at its top level.
367 .B +d
368 does NOT descend the directory tree, rooted at
369 .IR s .
370 The
371 .BI +D " D"
372 option may be used to request a full\-descent directory tree search,
373 rooted at directory
374 .IR D .
375 .IP
376 Processing of the
377 .B +d
378 option does not follow symbolic links within
379 .I s
380 unless the
381 .B \-x
382 or
383 .B \-x " l"
384 option is also specified.
385 Nor does it
386 search for open files on file system mount points on subdirectories of
387 .I s
388 unless the
389 .B \-x
390 or
391 .B \-x " f"
392 option is also specified.
393 .IP
394 Note: the authority of the user of this option limits it to searching for
395 files that the user has permission to examine with the system
396 .IR stat (2)
397 function.
398 .TP \w'names'u+4
399 .BI \-d " s"
400 specifies a list of file descriptors (FDs) to exclude from
401 or include in the output listing.
402 The file descriptors are specified in the comma\-separated set
403 .I s
404 \&\- e.g., ``cwd,1,3'', ``^6,^2''.
405 (There should be no spaces in the set.)
406 .IP
407 The list is an exclusion list if all entries of the set begin with `^'.
408 It is an inclusion list if no entry begins with `^'.
409 Mixed lists are not permitted.
410 .IP
411 A file descriptor number range may be in the set as long as
412 neither member is empty, both members are numbers, and the ending
413 member is larger than the starting one \- e.g., ``0-7'' or ``3-10''.
414 Ranges may be specified for exclusion if they have the `^' prefix \-
415 e.g., ``^0-7'' excludes all file descriptors 0 through 7.
416 .IP
417 Multiple file descriptor numbers are joined in a single ORed set before
418 participating in AND option selection.
419 .IP
420 When there are exclusion and inclusion members in the set,
421 .I lsof
422 reports them as errors and exits with a non\-zero return code.
423 .IP
424 See the description of File Descriptor (FD) output values in the
425 .B OUTPUT
426 section for more information on file descriptor names.
427 .TP \w'names'u+4
428 .BI +D " D"
429 causes
430 .I lsof
431 to search for all open instances of directory
432 .I D
433 and all the files and directories it contains to its complete depth.
434 .IP
435 Processing of the
436 .B +D
437 option does not follow symbolic links within
438 .I D
439 unless the
440 .B \-x
441 or
442 .B \-x " l"
443 option is also specified.
444 Nor does it
445 search for open files on file system mount points on subdirectories of
446 .I D
447 unless the
448 .B \-x
449 or
450 .B \-x " f"
451 option is also specified.
452 .IP
453 Note: the authority of the user of this option limits it to searching for
454 files that the user has permission to examine with the system
455 .IR stat (2)
456 function.
457 .IP
458 Further note:
459 .I lsof
460 may process this option slowly and require a large amount of dynamic memory
461 to do it.
462 This is because it must descend the entire directory tree, rooted at
463 .IR D ,
464 calling
465 .IR stat (2)
466 for each file and directory, building a list of all the files it finds, and
467 searching that list for a match with every open file.
468 When directory
469 .I D
470 is large, these steps can take a long time, so use this option prudently.
471 .TP \w'names'u+4
472 .BI \-D " D"
473 directs
474 .I lsof's
475 use of the device cache file.
476 The use of this option is sometimes restricted.
477 See the
478 .B "DEVICE CACHE FILE"
479 section and the sections that follow it for more information on this
480 option.
481 .IP
482 .B -D
483 must be followed by a function letter; the function letter may optionally
484 be followed by a path name.
485 .I Lsof
486 recognizes these function letters:
487 .IP
488 .nf
489         \fB?\fP \- report device cache file paths
490         \fBb\fP \- build the device cache file
491         \fBi\fP \- ignore the device cache file
492         \fBr\fP \- read the device cache file
493         \fBu\fP \- read and update the device cache file
494 .fi
495 .IP
496 The
497 .BR b ,
498 .BR r ,
499 and
500 .B u
501 functions, accompanied by a path name, are sometimes restricted.
502 When these functions are restricted, they will not appear in
503 the description of the
504 .B \-D
505 option that accompanies
506 .B \-h
507 or
508 .B \-?
509 option output.
510 See the
511 .B "DEVICE CACHE FILE"
512 section and the sections that follow it for more information on these
513 functions and when they're restricted.
514 .IP
515 The
516 .B ?
517 function reports the read\-only and write paths that lsof can
518 use for the device cache file,
519 the names of any environment variables whose values
520 .I lsof
521 will examine when forming the device cache file path,
522 and the format for the personal device cache file path.
523 (Escape the `?' character as your shell requires.)
524 .IP
525 When available, the
526 .BR b ,
527 .BR r ,
528 and
529 .B u
530 functions may be followed by the device cache file's path.
531 The standard default is
532 .I .lsof_hostname
533 in the home directory of the real user ID that executes
534 .IR lsof ,
535 but this could have been changed when
536 .I lsof
537 was configured and compiled.
538 (The output of the
539 .B \-h
540 and
541 .B \-?
542 options show the current default prefix \- e.g., ``.lsof''.)
543 The suffix,
544 .IR hostname ,
545 is the first component of the host's name returned by
546 .IR gethostname (2) .
547 .IP
548 When available, the
549 .B b
550 function directs
551 .I lsof
552 to build a new device cache file at the default or specified path.
553 .IP
554 The
555 .B i
556 function directs
557 .I lsof
558 to ignore the default device cache file and obtain its information
559 about devices via direct calls to the kernel.
560 .IP
561 The
562 .B r
563 function directs
564 .I lsof
565 to read the device cache at the default or specified path, but
566 prevents it from creating a new device cache file when none
567 exists or the existing one is improperly structured.
568 The
569 .B r
570 function, when specified without a path name, prevents
571 .I lsof
572 from updating an incorrect or outdated device cache file,
573 or creating a new one in its place.
574 The
575 .B r
576 function is always available when it is specified without a
577 path name argument; it may be restricted by the permissions of the
578 .I lsof
579 process.
580 .IP
581 When available, the
582 .B u
583 function directs
584 .I lsof
585 to read the device cache file at the default or specified path,
586 if possible, and to rebuild it, if necessary.
587 This is the default device cache file function when no
588 .B \-D
589 option has been specified.
590 .TP \w'names'u+4
591 .BI +|\-e " s"
592 exempts the file system whose path name is
593 .I s
594 from being subjected to kernel function calls that might block.
595 The
596 .B +e
597 option exempts
598 .IR stat (2),
599 .IR lstat (2)
600 and most
601 .IR readlink (2)
602 kernel function calls.
603 The
604 .B \-e
605 option exempts only
606 .IR stat(2)
607 and
608 .IR lstat (2)
609 kernel function calls.
610 Multiple file systems may be specified with separate
611 .B +|\-e
612 specifications and each may have
613 .IR readlink (2)
614 calls exempted or not.
615 .IP
616 This option is currently implemented only for Linux.
617 .IP
618 .B CAUTION:
619 this option can easily be mis\-applied to other than
620 the file system of interest, because it uses path name rather
621 than the more reliable device and inode numbers.
622 (Device and inode numbers are acquired via the potentially blocking
623 .IR stat (2)
624 kernel call and are thus not available, but see the
625 .BI +|\-m " m"
626 option as a possible alternative way to supply device numbers.)
627 \fBUse this option with great care and fully specify the path name of the
628 file system to be exempted.\fP
629 .IP
630 When open files on exempted file systems are reported, it may not be
631 possible to obtain all their information.
632 Therefore, some information columns will be blank, the characters ``UNKN''
633 preface the values in the TYPE column, and the applicable exemption option
634 is added in parentheses to the end of the NAME column.
635 (Some device number information might be made available via the
636 .BI +|\-m " m"
637 option.)
638 .TP \w'names'u+4
639 .B +|-E
640 .B +E
641 specifies that Linux files should be displayed with endpoint
642 information and the files of the endpoints should also be
643 displayed.
644 .IP
645 Endpoint information is displayed in the NAME column in the
646 form ``\fIPID,cmd,FDmode\fP''.
647 .I PID
648 is the endpoint process ID;
649 .I cmd
650 is the endpoint process command;
651 .I FD
652 is the endpoint file's descriptor; and
653 .I mode
654 is the endpoint file's access mode.
655 Multiple occurrences of this information can appear in a file's
656 NAME column.
657 .IP
658 .B -E
659 specfies that Linux pipe files should only be displayed with endpoint
660 information.
661 .TP \w'names'u+4
662 .B +|\-f [cfgGn]
663 .B f
664 by itself clarifies how path name arguments are to be interpreted.
665 When followed by
666 .BR c ,
667 .BR f ,
668 .BR g ,
669 .BR G ,
670 or
671 .B n
672 in any combination it specifies
673 that the listing of kernel file structure information is to be enabled
674 (`+') or inhibited (`\-').
675 .IP
676 Normally a path name argument is taken to be a file system name if
677 it matches a mounted\-on directory name reported by
678 .IR mount (8),
679 or if it represents a block device, named in the
680 .I mount
681 output and associated with a mounted directory name.
682 When
683 .B +f
684 is specified, all path name arguments will be taken to be file
685 system names, and
686 .I lsof
687 will complain if any are not.
688 This can be useful, for example, when the file system name
689 (mounted\-on device) isn't a block device.
690 This happens for some CD-ROM file systems.
691 .IP
692 When
693 .B \-f
694 is specified by itself, all path name arguments will be taken to be
695 simple files.
696 Thus, for example, the ``\fB\-f\fP\ -- /'' arguments direct lsof to search
697 for open files with a `/' path name, not all open files in the `/'
698 (root) file system.
699 .IP
700 Be careful to make sure
701 .B +f
702 and
703 .B \-f
704 are properly terminated and aren't followed by a character (e.g., of
705 the file or file system name) that might be taken as a parameter.
706 For example, use ``--'' after
707 .B +f
708 and
709 .B \-f
710 as in these examples.
711 .IP
712 .nf
713         $ lsof +f -- /file/system/name
714         $ lsof -f -- /file/name
715 .fi
716 .IP
717 The listing of information from kernel file structures, requested with the
718 .B +f [cfgGn]
719 option form, is normally
720 inhibited, and is not available in whole or part for some dialects \- e.g.,
721 /proc\-based Linux kernels below 2.6.22.
722 When the prefix to
723 .B f
724 is a plus sign (`+'), these characters request file structure information:
725 .IP
726 .nf
727         \fBc\fR file structure use count (not Linux)
728         \fBf\fR file structure address (not Linux)
729         \fBg\fR file flag abbreviations (Linux 2.6.22 and up)
730         \fBG\fR file flags in hexadecimal (Linux 2.6.22 and up)
731         \fBn\fR file structure node address (not Linux)
732 .fi
733 .IP
734 When the prefix is minus (`\-') the same characters disable the
735 listing of the indicated values.
736 .IP
737 File structure addresses, use counts, flags, and node addresses may be
738 used to detect more readily identical files inherited by child
739 processes and identical files in use by different processes.
740 .I Lsof
741 column output can be sorted by output columns holding the values
742 and listed to identify identical file use, or
743 .I lsof
744 field output can be parsed by an AWK or Perl post\-filter script,
745 or by a C program.
746 .TP \w'names'u+4
747 .BI \-F " f"
748 specifies a character list,
749 .IR f ,
750 that selects the fields to be output for processing by another program,
751 and the character that terminates each output field.
752 Each field to be output is specified with a single character in
753 .IR f .
754 The field terminator defaults to NL, but may be changed to NUL (000).
755 See the
756 .B "OUTPUT FOR OTHER PROGRAMS"
757 section for a description of the field identification characters and
758 the field output process.
759 .IP
760 When the field selection character list is empty, all standard fields are
761 selected (except the raw device field, security context and zone field for
762 compatibility reasons)
763 and the NL field terminator is used.
764 .IP
765 When the field selection character list contains only a zero (`0'),
766 all fields are selected (except the raw device field for compatibility
767 reasons) and the NUL terminator character is used.
768 .IP
769 Other combinations of fields and their associated field terminator
770 character must be set with explicit entries in
771 .IR f ,
772 as described in the
773 .B "OUTPUT FOR OTHER PROGRAMS"
774 section.
775 .IP
776 When a field selection character identifies an item
777 .I lsof
778 does not normally list \- e.g., PPID, selected with
779 .BR \-R " \-"
780 specification of the field character \- e.g., ``\fB\-FR\fP'' \-
781 also selects the listing of the item.
782 .IP
783 When the field selection character list contains the single
784 character `?',
785 .I lsof
786 will display a help list of the field identification characters.
787 (Escape the `?' character as your shell requires.)
788 .TP \w'names'u+4
789 .BI \-g " [s]"
790 excludes or selects the listing of files for the processes
791 whose optional process group IDentification (PGID) numbers are in the
792 comma\-separated set
793 .I s
794 \&\- e.g., ``123'' or ``123,^456''.
795 (There should be no spaces in the set.)
796 .IP
797 PGID numbers that begin with `^' (negation) represent exclusions.
798 .IP
799 Multiple PGID numbers are joined in a single ORed set before participating
800 in AND option selection.
801 However, PGID exclusions are applied without ORing or ANDing
802 and take effect before other selection criteria are applied.
803 .IP
804 The
805 .B \-g
806 option also enables the output display of PGID numbers.
807 When specified without a PGID set that's all it does.
808 .TP \w'names'u+4
809 .BI \-i " [i]"
810 selects the listing of files any of whose Internet address
811 matches the address specified in \fIi\fP.
812 If no address is specified, this option selects the listing of all
813 Internet and x.25 (HP\-UX) network files.
814 .IP
815 If
816 .BI \-i 4
817 or
818 .BI \-i 6
819 is specified with no following address, only files of the indicated
820 IP version, IPv4 or IPv6, are displayed.
821 (An IPv6 specification may be used only if the dialects supports IPv6,
822 as indicated by ``[46]'' and ``IPv[46]'' in
823 .I lsof's
824 .B \-h
825 or
826 .B \-?
827 output.)
828 Sequentially specifying
829 .BR \-i 4,
830 followed by
831 .BR \-i 6
832 is the same as specifying
833 .BR \-i ,
834 and vice-versa.
835 Specifying
836 .BR \-i 4,
837 or
838 .BR \-i 6
839 after
840 .B \-i
841 is the same as specifying
842 .BR \-i 4
843 or
844 .BR \-i 6
845 by itself.
846 .IP
847 Multiple addresses (up to a limit of 100) may be specified with multiple
848 .B \-i
849 options.
850 (A port number or service name range is counted as one address.)
851 They are joined in a single ORed set before participating in
852 AND option selection.
853 .IP
854 An Internet address is specified in the form (Items in square
855 brackets are optional.):
856 .IP
857 [\fI46\fP][\fIprotocol\fP][@\fIhostname\fP\||\|\fIhostaddr\fP][:\fIservice\fP\||\|\fIport\fP]
858 .IP
859 where:
860 .nf
861 .br
862         \fI46\fP specifies the IP version, IPv4 or IPv6
863 .br
864                 that applies to the following address.
865 .br
866                 '6' may be be specified only if the UNIX
867 .br
868                 dialect supports IPv6.  If neither '4' nor
869 .br
870                 '6' is specified, the following address
871 .br
872                 applies to all IP versions.
873 .br
874         \fIprotocol\fP is a protocol name \- \fBTCP\fP, \fBUDP\fP
875 .br             or \fBUDPLITE\fP.
876 .br
877         \fIhostname\fP is an Internet host name.  Unless a
878 .br
879                 specific IP version is specified, open
880 .br
881                 network files associated with host names
882 .br
883                 of all versions will be selected.
884 .br
885         \fIhostaddr\fP is a numeric Internet IPv4 address in
886 .br
887                 dot form; or an IPv6 numeric address in
888 .br
889                 colon form, enclosed in brackets, if the
890 .br
891                 UNIX dialect supports IPv6.  When an IP
892 .br
893                 version is selected, only its numeric
894 .br
895                 addresses may be specified.
896 .br
897         \fIservice\fP is an \fI/etc/services\fP name \- e.g., \fBsmtp\fP \-
898                 or a list of them.
899 .br
900         \fIport\fP is a port number, or a list of them.
901 .fi
902 .IP
903 IPv6 options may be used only if the UNIX dialect supports IPv6.
904 To see if the dialect supports IPv6, run
905 .I lsof
906 and specify the
907 .B \-h
908 or
909 .B \-?
910 (help) option.
911 If the displayed description of the
912 .B \-i
913 option contains ``[46]'' and ``IPv[46]'', IPv6 is supported.
914 .IP
915 IPv4 host names and addresses may not be specified if network file selection
916 is limited to IPv6 with
917 .BR \-i " 6."
918 IPv6 host names and addresses may not be specified if network file selection
919 is limited to IPv4 with
920 .BR \-i " 4."
921 When an open IPv4 network file's address is mapped in an IPv6 address,
922 the open file's type will be IPv6, not IPv4, and its display will be
923 selected by '6', not '4'.
924 .IP
925 At least one address component \-
926 .BR 4,
927 .BR 6,
928 .IR protocol ,
929 .IR hostname ,
930 .IR hostaddr ,
931 or
932 .I service
933 \&\- must be supplied.
934 The `@' character, leading the host specification, is always required;
935 as is the `:', leading the port specification.
936 Specify either
937 .I hostname
938 or
939 .IR hostaddr .
940 Specify either
941 .I service
942 name list or
943 .I port
944 number list.
945 If a
946 .I service
947 name list is specified, the
948 .I protocol
949 may also need to be specified if the TCP, UDP and UDPLITE port numbers for
950 the service name are different.
951 Use any case \- lower or upper \- for
952 .IR protocol .
953 .IP
954 .I Service
955 names and
956 .I port
957 numbers may be combined in a list whose entries are separated by commas
958 and whose numeric range entries are separated by minus signs.
959 There may be no embedded spaces, and all service names must belong to
960 the specified
961 .IR protocol .
962 Since service names may contain embedded minus signs, the starting entry
963 of a range can't be a service name; it can be a port number, however.
964 .IP
965 Here are some sample addresses:
966 .nf
967
968 .br
969         -i6 \- IPv6 only
970 .br
971         TCP:25 \- TCP and port 25
972 .br
973         @1.2.3.4 \- Internet IPv4 host address 1.2.3.4
974 .br
975         @[3ffe:1ebc::1]:1234 \- Internet IPv6 host address
976                 3ffe:1ebc::1, port 1234
977 .br
978         UDP:who \- UDP who service port
979 .br
980         TCP@lsof.itap:513 \- TCP, port 513 and host name lsof.itap
981 .br
982         tcp@foo:1-10,smtp,99 \- TCP, ports 1 through 10,
983                 service name \fIsmtp\fP, port 99, host name foo
984 .br
985         tcp@bar:1-smtp \- TCP, ports 1 through \fIsmtp\fP, host bar
986 .br
987         :time \- either TCP, UDP or UDPLITE time service port
988 .fi
989 .TP \w'names'u+4
990 .B \-K
991 selects the listing of tasks (threads) of processes, on dialects
992 where task (thread) reporting is supported.
993 (If help output \- i.e., the output of the
994 .B \-h
995 or
996 .B \-?
997 options \- shows this option, then task (thread) reporting is
998 supported by the dialect.)
999 .IP
1000 When
1001 .B \-K
1002 and
1003 .B \-a
1004 are both specified on Linux, and the tasks of a main process are
1005 selected by other options, the main process will also be listed
1006 as though it were a task, but without a task ID.
1007 (See the description of the TID column in the
1008 .B OUTPUT
1009 section.)
1010 .IP
1011 Where the FreeBSD version supports threads, all threads will be
1012 listed with their IDs.
1013 .IP
1014 In general threads and tasks inherit the files of the caller, but
1015 may close some and open others, so
1016 .I lsof
1017 always reports all the open files of threads and tasks.
1018 .TP \w'names'u+4
1019 .BI \-k " k"
1020 specifies a kernel name list file,
1021 .IR k ,
1022 in place of /vmunix, /mach, etc.
1023 .B \-k
1024 is not available under AIX on the IBM RISC/System 6000.
1025 .TP \w'names'u+4
1026 .B \-l
1027 inhibits the conversion of user ID numbers to login names.
1028 It is also useful when login name lookup is working improperly or slowly.
1029 .TP \w'names'u+4
1030 .BI +|\-L " [l]"
1031 enables (`+') or disables (`-') the listing of file link
1032 counts, where they are available \- e.g., they aren't available
1033 for sockets, or most FIFOs and pipes.
1034 .IP
1035 When
1036 .B +L
1037 is specified without a following number, all link counts will be listed.
1038 When
1039 .B \-L
1040 is specified (the default), no link counts will be listed.
1041 .IP
1042 When
1043 .B +L
1044 is followed by a number, only files having a link count less than
1045 that number will be listed.
1046 (No number may follow
1047 .BR \-L .)
1048 A specification of the form ``\fB+L1\fP'' will select open files that
1049 have been unlinked.
1050 A specification of the form ``\fB+aL1\ \fI<file_system>\fR'' will select
1051 unlinked open files on the specified file system.
1052 .IP
1053 For other link count comparisons, use field output (\fB\-F\fP)
1054 and a post\-processing script or program.
1055 .TP \w'names'u+4
1056 .BI +|\-m " m"
1057 specifies an alternate kernel memory file or activates
1058 mount table supplement processing.
1059 .IP
1060 The option form
1061 .BI \-m " m"
1062 specifies a kernel memory file,
1063 .IR m ,
1064 in place of
1065 .I /dev/kmem
1066 or
1067 .I /dev/mem
1068 \&\- e.g., a crash dump file.
1069 .IP
1070 The option form
1071 .B +m
1072 requests that a mount supplement file be written to the standard output
1073 file.
1074 All other options are silently ignored.
1075 .IP
1076 There will be a line in the mount supplement file for each mounted file
1077 system, containing the mounted file system directory, followed by a single
1078 space, followed by the device number in hexadecimal "0x" format \- e.g.,
1079 .IP
1080 .nf
1081         / 0x801
1082 .fi
1083 .IP
1084 .I Lsof
1085 can use the mount supplement file to get device numbers for file systems
1086 when it can't get them via
1087 .IR stat (2)
1088 or
1089 .IR lstat (2).
1090 .IP
1091 The option form
1092 .BI +m " m"
1093 identifies
1094 .I m
1095 as a mount supplement file.
1096 .IP
1097 Note: the
1098 .B +m
1099 and
1100 .BI +m " m"
1101 options are not available for all supported dialects.
1102 Check the output of
1103 .I lsof's
1104 .B \-h
1105 or
1106 .B \-?
1107 options to see if the
1108 .B +m
1109 and
1110 .BI +m " m"
1111 options are available.
1112 .TP \w'names'u+4
1113 .B +|\-M
1114 Enables (\fB+\fP) or disables (\fB-\fP) the
1115 reporting of portmapper registrations for local TCP, UDP and UDPLITE ports,
1116 where port mapping is supported.
1117 (See the last paragraph of this option description for information about
1118 where portmapper registration reporting is suported.)
1119 .IP
1120 The default reporting mode is set by the
1121 .I lsof
1122 builder with the HASPMAPENABLED #define in the dialect's machine.h
1123 header file;
1124 .I lsof
1125 is distributed with the HASPMAPENABLED #define deactivated, so
1126 portmapper reporting is disabled by default and must be requested
1127 with
1128 .BR \+M .
1129 Specifying
1130 .I lsof's
1131 .B \-h
1132 or
1133 .B \-?
1134 option will report the default mode.
1135 Disabling portmapper registration when it is already disabled or
1136 enabling it when already enabled is acceptable.
1137 When portmapper registration reporting is enabled,
1138 .I lsof
1139 displays the portmapper registration (if any) for local TCP, UDP or
1140 UDPLITE ports
1141 in square brackets immediately following the port numbers or service
1142 names \- e.g., ``:1234[name]'' or ``:name[100083]''.
1143 The registration information may be a name or number, depending
1144 on what the registering program supplied to the portmapper when
1145 it registered the port.
1146 .IP
1147 When portmapper registration reporting is enabled,
1148 .I lsof
1149 may run a little more slowly or even become blocked when access to the
1150 portmapper becomes congested or stopped.
1151 Reverse the reporting mode to determine if portmapper registration
1152 reporting is slowing or blocking
1153 .IR lsof .
1154 .IP
1155 For purposes of portmapper registration reporting
1156 .I lsof
1157 considers a TCP, UDP or UDPLITE port local if: it is found in the local part
1158 of its containing kernel structure;
1159 or if it is located in the foreign part of its containing kernel
1160 structure and the local and foreign Internet addresses are the same;
1161 or if it is located in the foreign part of its containing kernel
1162 structure and the foreign Internet address is INADDR_LOOPBACK (127.0.0.1).
1163 This rule may make
1164 .I lsof
1165 ignore some foreign ports on machines with multiple interfaces
1166 when the foreign Internet address is on a different interface
1167 from the local one.
1168 .IP
1169 See the
1170 .I lsof
1171 FAQ (The \fBFAQ\fP section gives its location.)
1172 for further discussion of portmapper registration
1173 reporting issues.
1174 .IP
1175 Portmapper registration reporting is supported only on dialects that
1176 have RPC header files.
1177 (Some Linux distributions with GlibC 2.14 do not have them.)
1178 When portmapper registration reporting is supported, the
1179 .B \-h
1180 or
1181 .B \-?
1182 help output will show the
1183 .B +|\-M
1184 option.
1185 .TP \w'names'u+4
1186 .B \-n
1187 inhibits the conversion of network numbers to 
1188 host names for network files.
1189 Inhibiting conversion may make
1190 .I lsof
1191 run faster.
1192 It is also useful when host name lookup is not working properly.
1193 .TP \w'names'u+4
1194 .B \-N
1195 selects the listing of NFS files.
1196 .TP \w'names'u+4
1197 .BI \-o
1198 directs
1199 .I lsof
1200 to display file offset at all times.
1201 It causes the SIZE/OFF output column title to be changed to OFFSET.
1202 Note: on some UNIX dialects
1203 .I lsof
1204 can't obtain accurate or consistent file offset information from its
1205 kernel data sources, sometimes just for particular kinds of files
1206 (e.g., socket files.)
1207 Consult the
1208 .I lsof
1209 FAQ (The \fBFAQ\fP section gives its location.)
1210 for more information.
1211 .IP
1212 The
1213 .B \-o
1214 and
1215 .B \-s
1216 options are mutually exclusive; they can't both be specified.
1217 When neither is specified,
1218 .I lsof
1219 displays whatever value \- size or offset \- is appropriate and
1220 available for the type of the file.
1221 .TP \w'names'u+4
1222 .BI \-o " o"
1223 defines the number of decimal digits (\fIo\fP) to be
1224 printed after the ``0t'' for a file offset before the form is switched
1225 to ``0x...''.
1226 An
1227 .I o
1228 value of zero (unlimited) directs
1229 .I lsof
1230 to use the ``0t'' form for all offset output.
1231 .IP
1232 This option does NOT direct
1233 .I lsof
1234 to display offset at all times; specify
1235 .B \-o
1236 (without a trailing number) to do that.
1237 .BI \-o " o"
1238 only specifies the number of digits after ``0t'' in
1239 either mixed size and offset or offset\-only output.
1240 Thus, for example, to direct
1241 .I lsof
1242 to display offset at all times with a decimal digit count of 10, use:
1243 .IP
1244 .nf
1245         -o -o 10
1246 or
1247         -oo10
1248 .fi
1249 .IP
1250 The default number of digits allowed after ``0t'' is normally 8,
1251 but may have been changed by the lsof builder.
1252 Consult the description of the
1253 .BI \-o " o"
1254 option in the output of the
1255 .B \-h
1256 or
1257 .B \-?
1258 option to determine the default that is in effect.
1259 .TP \w'names'u+4
1260 .B \-O
1261 directs
1262 .I lsof
1263 to bypass the strategy it uses to avoid being blocked by some
1264 kernel operations \- i.e., doing them in forked child processes.
1265 See the
1266 .B "BLOCKS AND TIMEOUTS"
1267 and
1268 .B "AVOIDING KERNEL BLOCKS"
1269 sections for more information on kernel operations that may block
1270 .IR lsof .
1271 .IP
1272 While use of this option will reduce
1273 .I lsof
1274 startup overhead, it may also cause
1275 .I lsof
1276 to hang when the kernel doesn't respond to a function.
1277 Use this option cautiously.
1278 .TP \w'names'u+4
1279 .BI \-p " s"
1280 excludes or selects the listing of files for the processes
1281 whose optional process IDentification (PID) numbers are in the
1282 comma\-separated set
1283 .I s
1284 \&\- e.g., ``123'' or ``123,^456''.
1285 (There should be no spaces in the set.)
1286 .IP
1287 PID numbers that begin with `^' (negation) represent exclusions.
1288 .IP
1289 Multiple process ID numbers are joined in a single ORed set before
1290 participating in AND option selection.
1291 However, PID exclusions are applied without ORing or ANDing
1292 and take effect before other selection criteria are applied.
1293 .TP \w'names'u+4
1294 .B \-P
1295 inhibits the conversion of port numbers to port
1296 names for network files.
1297 Inhibiting the conversion may make
1298 .I lsof
1299 run a little faster.
1300 It is also useful when port name lookup is not working properly.
1301 .TP \w'names'u+4
1302 .BI +|\-r " [t[m<fmt>]]"
1303 puts
1304 .I lsof
1305 in repeat mode.
1306 There
1307 .I lsof
1308 lists open files as selected by other options, delays
1309 .I t
1310 seconds (default fifteen), then repeats the listing, delaying
1311 and listing repetitively until stopped by a condition defined by
1312 the prefix to the option.
1313 .IP
1314 If the prefix is a `\-', repeat mode is endless.
1315 .I Lsof
1316 must be terminated with an interrupt or quit signal.
1317 .IP
1318 If the prefix is `+', repeat mode will end the first cycle no open files
1319 are listed \- and of course when
1320 .I lsof
1321 is stopped with an interrupt or quit signal.
1322 When repeat mode ends because no files are listed, the process exit code
1323 will be zero if any open files were ever listed; one, if none were ever
1324 listed.
1325 .IP
1326 .I Lsof
1327 marks the end of each listing:
1328 if field output is in progress (the
1329 .BR \-F ,
1330 option has been specified), the default marker is `m'; otherwise the
1331 default marker is ``========''.
1332 The marker is followed by a NL character.
1333 .IP
1334 The optional "m<fmt>" argument specifies a format for the marker line.
1335 The <fmt> characters following `m' are interpreted as a format
1336 specification to the
1337 .IR strftime (3)
1338 function, when both it and the
1339 .IR localtime (3)
1340 function are available in the dialect's C library.
1341 Consult the
1342 .IR strftime (3)
1343 documentation for what may appear in its format specification.
1344 Note that when field output is requested with the
1345 .B \-F
1346 option, <fmt> cannot contain the NL format, ``%n''.
1347 Note also that when <fmt> contains spaces or other characters that
1348 affect the shell's interpretation of arguments, <fmt> must be
1349 quoted appropriately.
1350 .IP
1351 Repeat mode reduces
1352 .I lsof
1353 startup overhead, so it is more efficient to use this mode
1354 than to call
1355 .I lsof
1356 repetitively from a shell script, for example.
1357 .IP
1358 To use repeat mode most efficiently, accompany
1359 .B +|\-r
1360 with specification of other
1361 .I lsof
1362 selection options, so the amount of kernel memory access
1363 .I lsof
1364 does will be kept to a minimum.
1365 Options that filter at the process level \- e.g.,
1366 .BR \-c ,
1367 .BR \-g ,
1368 .BR \-p ,
1369 .B \-u
1370 \&\- are the most efficient selectors.
1371 .IP
1372 Repeat mode is useful when coupled with field output (see the
1373 .BR \-F ,
1374 option description) and a supervising
1375 .I awk
1376 or
1377 .I Perl
1378 script, or a C program.
1379 .TP \w'names'u+4
1380 .B \-R
1381 directs lsof to list the Parent Process IDentification
1382 number in the PPID column.
1383 .TP \w'names'u+4
1384 .BI \-s " [p:s]"
1385 .B s
1386 alone directs
1387 .I lsof
1388 to display file size at all times.
1389 It causes the SIZE/OFF output column title to be changed to SIZE.
1390 If the file does not have a size, nothing is displayed.
1391 .IP
1392 The optional
1393 .BI \-s " p:s"
1394 form is available only for selected dialects, and only when the
1395 .B \-h
1396 or
1397 .B \-?
1398 help output lists it.
1399 .IP
1400 When the optional form is available, the
1401 .B s
1402 may be followed by a protocol name (\fIp\fR), either TCP or UDP,
1403 a colon (`:') and a comma\-separated protocol state name list,
1404 the option causes open TCP and UDP files to be excluded if their
1405 state name(s) are in the list (\fIs\fP) preceded by a `^'; or
1406 included if their name(s) are not preceded by a `^'.
1407 .IP
1408 When an inclusion list is defined, only network files with state
1409 names in the list will be present in the
1410 .I lsof
1411 output.
1412 Thus, specifying one state name means that only network files
1413 with that lone state name will be listed.
1414 .IP
1415 Case is unimportant in the protocol or state names, but there may
1416 be no spaces and the colon (`:') separating the protocol
1417 name (\fIp\fP) and the state name list (\fIs\fP) is required.
1418 .IP
1419 If only TCP and UDP files are to be listed, as controlled by
1420 the specified exclusions and inclusions, the
1421 .B \-i
1422 option must be specified, too.
1423 If only a single protocol's files are to be listed, add its name
1424 as an argument to the
1425 .B \-i
1426 option.
1427 .IP
1428 For example, to list only network files with TCP state LISTEN, use:
1429 .IP
1430 .nf
1431         \-iTCP \-sTCP:LISTEN
1432 .fi
1433 .IP
1434 Or, for example, to list network files with all UDP states except
1435 Idle, use:
1436 .IP
1437 .nf
1438         \-iUDP -sUDP:Idle
1439 .fi
1440 .IP
1441 State names vary with UNIX dialects, so it's not possible to
1442 provide a complete list.  Some common TCP state names are:
1443 CLOSED, IDLE, BOUND, LISTEN, ESTABLISHED, SYN_SENT, SYN_RCDV,
1444 ESTABLISHED, CLOSE_WAIT, FIN_WAIT1, CLOSING, LAST_ACK, FIN_WAIT_2,
1445 and TIME_WAIT.
1446 Two common UDP state names are Unbound and Idle.
1447 .IP
1448 See the
1449 .I lsof
1450 FAQ (The \fBFAQ\fP section gives its location.)
1451 for more information on how to use protocol state exclusion and
1452 inclusion, including examples.
1453 .IP
1454 The
1455 .B \-o
1456 (without a following decimal digit count) and
1457 .B \-s
1458 option (without a following protocol and state name list)
1459 are mutually exclusive; they can't both be specified.
1460 When neither is specified,
1461 .I lsof
1462 displays whatever value \- size or offset \- is appropriate and
1463 available for the type of file.
1464 .IP
1465 Since some types of files don't have true sizes \- sockets, FIFOs,
1466 pipes, etc. \- lsof displays for their sizes the content amounts in
1467 their associated kernel buffers, if possible.
1468 .TP \w'names'u+4
1469 .BI \-S " [t]"
1470 specifies an optional time-out seconds value for kernel functions \-
1471 .IR lstat (2),
1472 .IR readlink (2),
1473 and
1474 .IR stat (2)
1475 \- that might otherwise deadlock.
1476 The minimum for
1477 .I t
1478 is two;
1479 the default, fifteen; when no value is specified, the default is used.
1480 .IP
1481 See the
1482 .B "BLOCKS AND TIMEOUTS"
1483 section for more information.
1484 .TP \w'names'u+4
1485 .BI \-T " [t]"
1486 controls the reporting of some TCP/TPI information, also
1487 reported by
1488 .IR netstat (1),
1489 following the network addresses.
1490 In normal output the information appears in parentheses, each item
1491 except TCP or TPI state name identified by a keyword, followed by `=',
1492 separated from others by a single space:
1493 .IP
1494 .nf
1495         <TCP or TPI state name>
1496         QR=<read queue length>
1497         QS=<send queue length>
1498         SO=<socket options and values>
1499         SS=<socket states>
1500         TF=<TCP flags and values>
1501         WR=<window read length>
1502         WW=<window write length>
1503 .fi
1504 .IP
1505 Not all values are reported for all UNIX dialects.
1506 Items values (when available) are reported after the item name and '='.
1507 .IP
1508 When the field output mode is in effect (See
1509 .BR "OUTPUT FOR OTHER PROGRAMS" .)
1510 each item appears as a field with a `T' leading character.
1511 .IP
1512 .B \-T
1513 with no following key characters disables TCP/TPI information reporting.
1514 .IP
1515 .B \-T
1516 with following characters selects the reporting of specific TCP/TPI
1517 information:
1518 .IP
1519 .nf
1520         \fBf\fP selects reporting of socket options,
1521                 states and values, and TCP flags and
1522                 values.
1523         \fBq\fP selects queue length reporting.
1524         \fBs\fP selects connection state reporting.
1525         \fBw\fP selects window size reporting.
1526 .fi
1527 .IP
1528 Not all selections are enabled for some UNIX dialects.
1529 State may be selected for all dialects and is reported by default.
1530 The
1531 .B \-h
1532 or
1533 .B \-?
1534 help output for the
1535 .B \-T
1536 option will show what selections may be used with the UNIX dialect.
1537 .IP
1538 When
1539 .B \-T
1540 is used to select information \- i.e., it is followed by one or more
1541 selection characters \- the displaying of state is disabled by default,
1542 and it must be explicitly selected again in the characters following
1543 .BR \-T .
1544 (In effect, then, the default is equivalent to
1545 .BR -Ts .)
1546 For example, if queue lengths and state are desired, use
1547 .BR \-Tqs .
1548 .IP
1549 Socket options, socket states, some socket values, TCP flags and
1550 one TCP value may be reported (when available in the UNIX dialect)
1551 in the form of the names that commonly appear after SO_, so_, SS_,
1552 TCP_  and TF_ in the dialect's header files \-
1553 most often <sys/socket.h>, <sys/socketvar.h> and <netinet/tcp_var.h>.
1554 Consult those header files for the meaning of the flags, options,
1555 states and values.
1556 .IP
1557 ``SO='' precedes socket options and values; ``SS='', socket states;
1558 and ``TF='', TCP flags and values.
1559 .IP
1560 If a flag or option has a value, the value will follow an '=' and
1561 the name -- e.g., ``SO=LINGER=5'', ``SO=QLIM=5'', ``TF=MSS=512''.
1562 The following seven values may be reported:
1563 .IP
1564 .nf
1565         Name
1566         Reported        Description (Common Symbol)
1567
1568         KEEPALIVE       keep alive time (SO_KEEPALIVE)
1569         LINGER  linger time (SO_LINGER)
1570         MSS             maximum segment size (TCP_MAXSEG)
1571         PQLEN   partial listen queue connections
1572         QLEN            established listen queue connections
1573         QLIM            established listen queue limit
1574         RCVBUF  receive buffer length (SO_RCVBUF)
1575         SNDBUF  send buffer length (SO_SNDBUF)
1576 .fi
1577 .IP
1578 Details on what socket options and values, socket states, and TCP flags
1579 and values may be displayed for particular UNIX dialects may be found in
1580 the answer to the ``Why doesn't lsof report socket options, socket states,
1581 and TCP flags and values for my dialect?'' and ``Why doesn't lsof report
1582 the partial listen queue connection count for my dialect?''
1583 questions in the
1584 .I lsof
1585 FAQ (The \fBFAQ\fP section gives its location.)
1586 .TP \w'names'u+4
1587 .B \-t 
1588 specifies that
1589 .I lsof
1590 should produce terse output with process identifiers only and no header \-
1591 e.g., so that the output may be piped to
1592 .IR kill (1).
1593 .B \-t
1594 selects the
1595 .B \-w
1596 option.
1597 .TP \w'names'u+4
1598 .BI \-u " s"
1599 selects the listing of files for the user whose login names
1600 or user ID numbers are in the comma\-separated set
1601 .I s
1602 \&\- e.g., ``abe'',
1603 or ``548,root''.
1604 (There should be no spaces in the set.)
1605 .IP
1606 Multiple login names or user ID numbers are joined in a single ORed set
1607 before participating in AND option selection.
1608 .IP
1609 If a login name or user ID is preceded by a `^', it becomes a negation \-
1610 i.e., files of processes owned by the login name or user ID will never
1611 be listed.
1612 A negated login name or user ID selection is neither ANDed nor ORed
1613 with other selections; it is applied before all other selections and
1614 absolutely excludes the listing of the files of the process.
1615 For example, to direct
1616 .I lsof
1617 to exclude the listing of files belonging to root processes,
1618 specify ``\-u^root'' or ``\-u^0''.
1619 .TP \w'names'u+4
1620 .B \-U
1621 selects the listing of UNIX domain socket files.
1622 .TP \w'names'u+4
1623 .B \-v
1624 selects the listing of
1625 .I lsof
1626 version information, including: revision number;
1627 when the
1628 .I lsof
1629 binary was constructed;
1630 who constructed the binary and where;
1631 the name of the compiler used to construct the
1632 .I lsof binary;
1633 the version number of the compiler when readily available;
1634 the compiler and loader flags used to construct the
1635 .I lsof
1636 binary;
1637 and system information, typically the output of
1638 .IR uname 's
1639 .B \-a
1640 option.
1641 .TP \w'names'u+4
1642 .B \-V
1643 directs
1644 .I lsof
1645 to indicate the items it was asked to list and failed to find \- command
1646 names, file names, Internet addresses or files, login names, NFS files,
1647 PIDs, PGIDs, and UIDs.
1648 .IP
1649 When other options are ANDed to search options, or compile\-time
1650 options restrict the listing of some files,
1651 .I lsof
1652 may not report that it failed to find a search item when an ANDed
1653 option or compile\-time option prevents the listing of the open file
1654 containing the located search item.
1655 .IP
1656 For example, ``lsof -V -iTCP@foobar -a -d 999'' may not report a
1657 failure to locate open files at ``TCP@foobar'' and may not list
1658 any, if none have a file descriptor number of 999.
1659 A similar situation arises when HASSECURITY and HASNOSOCKSECURITY are
1660 defined at compile time and they prevent the listing of open files.
1661 .TP \w'names'u+4
1662 .B +|\-w
1663 Enables (\fB+\fP) or disables (\fB-\fP) the suppression of warning messages.
1664 .IP
1665 The
1666 .I lsof
1667 builder may choose to have warning messages disabled or enabled by
1668 default.
1669 The default warning message state is indicated in the output of the
1670 .B \-h
1671 or
1672 .B \-?
1673 option.
1674 Disabling warning messages when they are already disabled or enabling
1675 them when already enabled is acceptable.
1676 .IP
1677 The
1678 .B \-t
1679 option selects the
1680 .B \-w
1681 option.
1682 .TP \w'names'u+4
1683 .BI \-x " [fl]"
1684 may accompany the
1685 .B +d
1686 and
1687 .B +D
1688 options to direct their processing to cross over symbolic
1689 links and|or file system mount points encountered when
1690 scanning the directory (\fB+d\fP) or directory tree (\fB+D\fP).
1691 .IP
1692 If
1693 .B -x
1694 is specified by itself without a following parameter, cross\-over
1695 processing of both symbolic links and file system mount points is
1696 enabled.
1697 Note that when
1698 .B \-x
1699 is specified without a parameter, the next argument must begin with '-'
1700 or '+'.
1701 .IP
1702 The optional 'f' parameter enables file system mount point cross\-over
1703 processing; 'l', symbolic link cross\-over processing.
1704 .IP
1705 The
1706 .B \-x
1707 option may not be supplied without also supplying a
1708 .B +d
1709 or
1710 .B +D
1711 option.
1712 .TP \w'names'u+4
1713 .B \-X
1714 This is a dialect\-specific option.
1715 .HP \w'names'u+4
1716 \ \ \ \ AIX:
1717 .br
1718 This IBM AIX RISC/System 6000 option requests the reporting
1719 of executed text file and shared library references.
1720 .IP
1721 .B WARNING:
1722 because this option uses the kernel readx() function, its use on
1723 a busy AIX system might cause an application process to hang so
1724 completely that it can neither be killed nor stopped.
1725 I have never seen this happen or had a report of its happening,
1726 but I think there is a remote possibility it could happen.
1727 .IP
1728 By default use of readx() is disabled.
1729 On AIX 5L and above
1730 .I lsof
1731 may need setuid\-root permission to perform the actions this
1732 option requests.
1733 .IP
1734 The
1735 .I lsof
1736 builder may specify that the
1737 .B \-X
1738 option be restricted to processes whose real UID is root.
1739 If that has been done, the
1740 .B \-X
1741 option will not appear in the
1742 .B \-h
1743 or
1744 .B \-?
1745 help output unless the real UID of the
1746 .I lsof
1747 process is root.
1748 The default
1749 .I lsof
1750 distribution allows any UID to specify
1751 .BR \-X,
1752 so by default it will appear in the help output.
1753 .IP
1754 When AIX readx() use
1755 is disabled,
1756 .I lsof
1757 may not be able to report information for all text and loader file
1758 references, but it may also avoid exacerbating an AIX
1759 kernel directory search kernel error, known as the Stale Segment
1760 ID bug.
1761 .IP
1762 The readx() function, used by
1763 .I lsof
1764 or any other program to access some sections of kernel virtual
1765 memory, can trigger the Stale Segment ID bug.
1766 It can cause the kernel's dir_search() function to believe erroneously
1767 that part of an in\-memory copy of a file system directory has been
1768 zeroed.
1769 Another application process, distinct from
1770 .IR lsof ,
1771 asking the kernel to search the directory \- e.g., by using
1772 .IR open "(2) \-"
1773 can cause dir_search() to loop forever, thus hanging the application process.
1774 .IP
1775 Consult the
1776 .I lsof
1777 FAQ (The \fBFAQ\fP section gives its location.)
1778 and the
1779 .I 00README
1780 file of the
1781 .I lsof
1782 distribution for a more complete description of the Stale Segment ID bug,
1783 its APAR, and methods for defining readx() use when compiling
1784 .IR lsof .
1785 .HP \w'names'u+4
1786 \ \ \ \ Linux:
1787 .br
1788 This Linux option requests that
1789 .I lsof
1790 skip the reporting of information on all open TCP, UDP and UDPLITE IPv4
1791 and IPv6 files.
1792 .IP
1793 This Linux option is most useful when the system has an extremely
1794 large number of open TCP, UDP and UDPLITE files, the processing of whose
1795 information in the
1796 .I /proc/net/tcp*
1797 and
1798 .I /proc/net/udp*
1799 files would take
1800 .I lsof
1801 a long time, and whose reporting is not of interest.
1802 .IP
1803 Use this option with care and only when you are sure that the
1804 information you want
1805 .I lsof
1806 to display isn't associated with open TCP, UDP or UDPLITE socket files.
1807 .HP \w'names'u+4
1808 \ \ \ \ Solaris 10 and above:
1809 .br
1810 This Solaris 10 and above option requests the reporting of cached
1811 paths for files that have been deleted \- i.e., removed with
1812 .IR rm (1)
1813 or
1814 .IR unlink (2).
1815 .IP
1816 The cached path is followed by the string ``\ (deleted)'' to indicate
1817 that the path by which the file was opened has been deleted.
1818 .IP
1819 Because intervening changes made to the path \- i.e., renames with
1820 .IR mv (1)
1821 or
1822 .IR rename (2)
1823 \- are not recorded in the cached path, what
1824 .I lsof
1825 reports is only the path by which the file was opened, not its
1826 possibly different final path.
1827 .TP \w'names'u+4
1828 .BI \-z " [z]"
1829 specifies how Solaris 10 and higher zone information is to be handled.
1830 .IP
1831 Without a following argument \- e.g., NO
1832 .IR z " \-"
1833 the option specifies that zone names are to be listed in the ZONE
1834 output column.
1835 .IP
1836 The
1837 .B \-z
1838 option may be followed by a zone name,
1839 .BI z .
1840 That causes lsof to list only open files for processes in that zone.
1841 Multiple
1842 .BI \-z " z"
1843 option and argument pairs may be specified to form a list of named zones.
1844 Any open file of any process in any of the zones will be listed, subject
1845 to other conditions specified by other options and arguments.
1846 .TP \w'names'u+4
1847 .BI \-Z " [Z]"
1848 specifies how SELinux security contexts are to be handled.
1849 It and 'Z' field output character support are inhibited
1850 when SELinux is disabled in the running Linux kernel.
1851 See
1852 .B "OUTPUT FOR OTHER PROGRAMS"
1853 for more information on the 'Z' field output character.
1854 .IP
1855 Without a following argument \- e.g., NO
1856 .IR Z " \-"
1857 the option specifies that security contexts are to be listed in the
1858 SECURITY\-CONTEXT output column.
1859 .IP
1860 The
1861 .B \-Z
1862 option may be followed by a wildcard security context name,
1863 .BI Z .
1864 That causes lsof to list only open files for processes in that security
1865 context.
1866 Multiple
1867 .BI \-Z " Z"
1868 option and argument pairs may be specified to form a list of security
1869 contexts.
1870 Any open file of any process in any of the security contexts will be listed,
1871 subject to other conditions specified by other options and arguments.
1872 Note that
1873 .I Z
1874 can be A:B:C or *:B:C or A:B:* or *:*:C to match against the A:B:C context.
1875 .TP \w'names'u+4
1876 .B --
1877 The double minus sign option is a marker that signals the end of
1878 the keyed options.
1879 It may be used, for example, when the first file name begins with
1880 a minus sign.
1881 It may also be used when the absence of a value for the last keyed
1882 option must be signified by the presence of a minus sign in the following
1883 option and before the start of the file names.
1884 .TP \w'names'u+4
1885 .I names
1886 These are path names of specific files to list.
1887 Symbolic links are resolved before use.
1888 The first name may be separated from the preceding options with
1889 the ``--'' option.
1890 .IP
1891 If a
1892 .I name 
1893 is the mounted\-on directory of a file system or the device of the
1894 file system,
1895 .I lsof
1896 will list all the files open on the file system.
1897 To be considered a file system, the
1898 .I name
1899 must match a mounted\-on directory name in
1900 .IR mount (8)
1901 output, or match the name of a block device associated with a mounted\-on
1902 directory name.
1903 The
1904 .B +|\-f
1905 option may be used to force
1906 .I lsof
1907 to consider a
1908 .I name
1909 a file system identifier (\fB+f\fP) or a simple file (\fB\-f\fP).
1910 .IP
1911 If
1912 .I name
1913 is a path to a directory that is not the mounted\-on directory name of
1914 a file system, it is treated just as a regular file is treated \- i.e.,
1915 its listing is restricted to processes that have it open as a file or
1916 as a process\-specific directory, such as the root or current working
1917 directory.
1918 To request that
1919 .I lsof
1920 look for open files inside a directory name, use the
1921 .BI +d " s"
1922 and
1923 .BI +D " D"
1924 options.
1925 .IP
1926 If a
1927 .I name
1928 is the base name of a family of multiplexed files \- e. g, AIX's
1929 .IR /dev/pt[cs] " \-"
1930 .I lsof
1931 will list all the associated multiplexed files on the device that
1932 are open \- e.g.,
1933 .IR /dev/pt[cs]/1 ,
1934 .IR /dev/pt[cs]/2 ,
1935 etc.
1936 .IP
1937 If a
1938 .I name
1939 is a UNIX domain socket name,
1940 .I lsof
1941 will usually search for it by the characters of the name alone \- exactly as
1942 it is specified and is recorded in the kernel socket structure.
1943 (See the next paragraph for an exception to that rule for Linux.)
1944 Specifying a relative path \- e.g.,
1945 .I ./file
1946 \&\- in place of the
1947 file's absolute path \- e.g.,
1948 .I /tmp/file
1949 \&\- won't work because
1950 .I lsof
1951 must match the characters you specify with what it finds in the
1952 kernel UNIX domain socket structures.
1953 .IP
1954 If a
1955 .I name
1956 is a Linux UNIX domain socket name, in one case
1957 .I lsof
1958 is able to search for it by its device and inode number, allowing
1959 .I name
1960 to be a relative path.
1961 The case requires that the absolute path -- i.e., one beginning with a
1962 slash ('/') be used by the process that created the socket, and hence be
1963 stored in the
1964 .I /proc/net/unix
1965 file; and it requires that
1966 .I lsof
1967 be able to obtain the device and node numbers of both the absolute path in
1968 .I /proc/net/unix
1969 and
1970 .I name
1971 via successful
1972 .IR stat (2)
1973 system calls.
1974 When those conditions are met,
1975 .I lsof
1976 will be able to search for the UNIX domain socket when some path to it is
1977 is specified in
1978 .IR name .
1979 Thus, for example, if the path is
1980 .IR /dev/log ,
1981 and an
1982 .I lsof
1983 search is initiated when the working directory is
1984 .IR /dev ,
1985 then
1986 .I name
1987 could be
1988 .IR ./log .
1989 .IP
1990 If a
1991 .I name
1992 is none of the above,
1993 .I lsof
1994 will list any open files whose device and inode match that of the
1995 specified path
1996 .IR name .
1997 .IP
1998 If you have also specified the
1999 .B \-b
2000 option,
2001 the only
2002 .I names
2003 you may safely specify are file systems for which your mount table
2004 supplies alternate device numbers.
2005 See the
2006 .B "AVOIDING KERNEL BLOCKS"
2007 and
2008 .B "ALTERNATE DEVICE NUMBERS"
2009 sections for more information.
2010 .IP
2011 Multiple file names are joined in a single ORed set before
2012 participating in AND option selection.
2013 .SH AFS
2014 .I Lsof
2015 supports the recognition of AFS files for these dialects (and AFS
2016 versions):
2017 .PP
2018 .nf
2019         AIX 4.1.4 (AFS 3.4a)
2020         HP\-UX 9.0.5 (AFS 3.4a)
2021         Linux 1.2.13 (AFS 3.3)
2022         Solaris 2.[56] (AFS 3.4a)
2023 .fi
2024 .PP
2025 It may recognize AFS files on other versions of these dialects,
2026 but has not been tested there.
2027 Depending on how AFS is implemented,
2028 .I lsof
2029 may recognize AFS files in other dialects, or may have difficulties
2030 recognizing AFS files in the supported dialects.
2031 .PP
2032 .I Lsof
2033 may have trouble identifying all aspects of AFS files in
2034 supported dialects when AFS kernel support is implemented via
2035 dynamic modules whose addresses do not appear in the kernel's
2036 variable name list.
2037 In that case,
2038 .I lsof
2039 may have to guess at the identity of AFS files, and might not be able to
2040 obtain volume information from the kernel that is needed for calculating
2041 AFS volume node numbers.
2042 When
2043 .I lsof
2044 can't compute volume node numbers, it reports blank in the NODE column.
2045 .PP
2046 The
2047 .BI \-A " A"
2048 option is available in some dialect implementations of
2049 .I lsof
2050 for specifying the name list file where dynamic module kernel
2051 addresses may be found.
2052 When this option is available, it will be listed in the
2053 .I lsof
2054 help output, presented in response to the
2055 .B \-h
2056 or
2057 .B \-?
2058 .PP
2059 See the
2060 .I lsof
2061 FAQ (The \fBFAQ\fP section gives its location.)
2062 for more information about dynamic modules, their
2063 symbols, and how they affect
2064 .I lsof
2065 options.
2066 .PP
2067 Because AFS path lookups don't seem to participate in the
2068 kernel's name cache operations,
2069 .I lsof
2070 can't identify path name components for AFS files.
2071 .SH SECURITY
2072 .I Lsof
2073 has three features that may cause security concerns.
2074 First, its default compilation mode allows anyone to list all
2075 open files with it.
2076 Second, by default it creates a user\-readable and user\-writable device
2077 cache file in the home directory of the real user ID that executes
2078 .IR lsof .
2079 (The list\-all\-open\-files and device cache features may be disabled when
2080 .I lsof
2081 is compiled.)
2082 Third, its
2083 .B \-k
2084 and
2085 .B \-m
2086 options name alternate kernel name list or memory files.
2087 .PP
2088 Restricting the listing of all open files is controlled by the
2089 compile\-time HASSECURITY and HASNOSOCKSECURITY options.
2090 When HASSECURITY is defined,
2091 .I lsof
2092 will allow only the root user to list all open files.
2093 The non\-root user may list only open files of processes with the same user
2094 IDentification number as the real user ID number of the
2095 .I lsof
2096 process (the one that its user logged on with).
2097 .PP
2098 However, if HASSECURITY and HASNOSOCKSECURITY are both defined,
2099 anyone may list open socket files, provided they are selected
2100 with the
2101 .B \-i
2102 option.
2103 .PP
2104 When HASSECURITY is not defined, anyone may list all open files.
2105 .PP
2106 Help output, presented in response to the
2107 .B \-h
2108 or
2109 .B \-?
2110 option, gives the status of the HASSECURITY and HASNOSOCKSECURITY definitions.
2111 .PP
2112 See the
2113 .B Security
2114 section of the
2115 .I 00README
2116 file of the
2117 .I lsof
2118 distribution for information on building
2119 .I lsof
2120 with the HASSECURITY and HASNOSOCKSECURITY options enabled.
2121 .PP
2122 Creation and use of a user\-readable and user\-writable device
2123 cache file is controlled by the compile\-time HASDCACHE option.
2124 See the
2125 .B "DEVICE CACHE FILE"
2126 section and the sections that follow it for details on how its path
2127 is formed.
2128 For security considerations it is important to note that in the default
2129 .I lsof
2130 distribution, if the real user ID under which
2131 .I lsof
2132 is executed is root, the device cache file will be written in root's
2133 home directory \- e.g.,
2134 .I /
2135 or
2136 .IR /root .
2137 When HASDCACHE is not defined,
2138 .I lsof
2139 does not write or attempt to read a device cache file.
2140 .PP
2141 When HASDCACHE is defined, the
2142 .I lsof
2143 help output, presented in response to the
2144 .BR \-h ,
2145 .BR \-D? ,
2146 or
2147 .B \-?
2148 options, will provide device cache file handling information.
2149 When HASDCACHE is not defined, the
2150 .B \-h
2151 or
2152 .B \-?
2153 output will have no
2154 .B \-D
2155 option description.
2156 .PP
2157 Before you decide to disable the device cache file feature \- enabling
2158 it improves the performance of
2159 .I lsof
2160 by reducing the startup overhead of examining all the nodes in
2161 .I /dev
2162 (or
2163 .IR /devices )
2164 \&\- read the discussion of it in the
2165 .I 00DCACHE
2166 file of the
2167 .I lsof
2168 distribution and the
2169 .I lsof
2170 FAQ (The \fBFAQ\fP section gives its location.)
2171 .PP
2172 WHEN IN DOUBT, YOU CAN TEMPORARILY DISABLE THE USE OF THE DEVICE CACHE FILE
2173 WITH THE
2174 .B \-Di
2175 OPTION.
2176 .PP
2177 When
2178 .I lsof
2179 user declares alternate kernel name list or memory files with the
2180 .B \-k
2181 and
2182 .B \-m
2183 options,
2184 .I lsof
2185 checks the user's authority to read them with
2186 .IR access (2).
2187 This is intended to prevent whatever special power
2188 .I lsof's
2189 modes might confer on it from letting it read files not normally
2190 accessible via the authority of the real user ID.
2191 .SH OUTPUT
2192 This section describes the information
2193 .I lsof
2194 lists for each open file.
2195 See the
2196 .B "OUTPUT FOR OTHER PROGRAMS"
2197 section for additional information on output that can be processed
2198 by another program.
2199 .PP
2200 .I Lsof
2201 only outputs printable (declared so by
2202 .IR isprint (3))
2203 8 bit characters.
2204 Non\-printable characters are printed in one of three forms:
2205 the C ``\\[bfrnt]'' form;
2206 the control character `^' form (e.g., ``^@'');
2207 or hexadecimal leading ``\\x'' form (e.g., ``\\xab'').
2208 Space is non\-printable in the COMMAND column (``\\x20'')
2209 and printable elsewhere.
2210 .PP
2211 For some dialects \- if HASSETLOCALE is defined in the dialect's
2212 machine.h header file \-
2213 .I lsof
2214 will print the extended 8 bit characters of a language locale.
2215 The
2216 .I lsof
2217 process must be supplied a language locale environment variable
2218 (e.g., LANG) whose value represents a known language locale
2219 in which the extended characters are considered printable by
2220 .IR isprint (3).
2221 Otherwise
2222 .I lsof
2223 considers the extended characters non\-printable and prints them according
2224 to its rules for non\-printable characters, stated above.
2225 Consult your dialect's
2226 .IR setlocale (3)
2227 man page for the names of other environment variables that may
2228 be used in place of LANG \- e.g., LC_ALL, LC_CTYPE, etc.
2229 .PP
2230 .I Lsof's
2231 language locale support for a dialect also covers wide characters \- e.g.,
2232 UTF-8 \- when HASSETLOCALE and HASWIDECHAR are defined in the dialect's
2233 machine.h header file, and when a suitable language locale has been defined
2234 in the appropriate environment variable for the
2235 .I lsof
2236 process.
2237 Wide characters are printable under those conditions if
2238 .IR iswprint (3)
2239 reports them to be.
2240 If HASSETLOCALE, HASWIDECHAR and a suitable language locale aren't defined,
2241 or if
2242 .IR iswprint (3)
2243 reports wide characters that aren't printable,
2244 .I lsof
2245 considers the wide characters non\-printable and prints each of their
2246 8 bits according to its rules for non\-printable characters, stated above.
2247 .PP
2248 Consult the answers to the "Language locale support" questions in the
2249 lsof FAQ (The \fBFAQ\fP section gives its location.) for more information.
2250 .PP
2251 .I Lsof
2252 dynamically sizes the output columns each time it runs, guaranteeing
2253 that each column is a minimum size.
2254 It also guarantees that each column is separated from its predecessor
2255 by at least one space.
2256 .TP \w'COMMAND'u+4
2257 COMMAND
2258 contains the first nine characters of the name of the UNIX command
2259 associated with the process.
2260 If a non\-zero
2261 .I w
2262 value is specified to the
2263 .BI +c " w"
2264 option, the column contains the first
2265 .I w
2266 characters of the name of the UNIX command associated with the process
2267 up to the limit of characters supplied to
2268 .I lsof
2269 by the UNIX dialect.
2270 (See the description of the
2271 .BI +c " w"
2272 command or the
2273 .I lsof
2274 FAQ for more information.
2275 The \fBFAQ\fP section gives its location.)
2276 .IP
2277 If
2278 .I w
2279 is less than the length of the column title, ``COMMAND'', it will
2280 be raised to that length.
2281 .IP
2282 If a zero
2283 .I w
2284 value is specified to the
2285 .BI +c " w"
2286 option, the column contains all the characters of the name of the UNIX command
2287 associated with the process.
2288 .IP
2289 All command name characters maintained by the kernel in its structures
2290 are displayed in field output when the command name descriptor (`c')
2291 is specified.
2292 See the
2293 .B "OUTPUT FOR OTHER COMMANDS"
2294 section for information on selecting field output and the associated
2295 command name descriptor.
2296 .TP
2297 PID
2298 is the Process IDentification number of the process.
2299 .TP
2300 TID
2301 is the task (thread) IDentification number, if task (thread)
2302 reporting is supported by the dialect and a task (thread) is
2303 being listed.
2304 (If help output \- i.e., the output of the
2305 .B \-h
2306 or
2307 .B \-?
2308 options \- shows this option, then task (thread) reporting is
2309 supported by the dialect.)
2310 .IP
2311 A blank TID column in Linux indicates a process \- i.e., a non\-task.
2312 .TP
2313 ZONE
2314 is the Solaris 10 and higher zone name.
2315 This column must be selected with the
2316 .B \-z
2317 option.
2318 .TP
2319 SECURITY\-CONTEXT
2320 is the SELinux security context.
2321 This column must be selected with the
2322 .B -Z
2323 option.
2324 Note that the
2325 .B -Z
2326 option is inhibited when SELinux is disabled in the running Linux
2327 kernel.
2328 .TP
2329 PPID
2330 is the Parent Process IDentification number of the process.
2331 It is only displayed when the
2332 .B \-R
2333 option has been specified.
2334 .TP
2335 PGID
2336 is the process group IDentification number associated with
2337 the process.
2338 It is only displayed when the
2339 .B \-g
2340 option has been specified.
2341 .TP
2342 USER
2343 is the user ID number or login name of the user to whom
2344 the process belongs, usually the same as reported by
2345 .IR ps (1).
2346 However, on Linux USER is the user ID number or login that owns
2347 the directory in /proc where
2348 .I lsof
2349 finds information about the process.
2350 Usually that is the same value reported by
2351 .IR ps (1),
2352 but may differ when the process has changed its effective user ID.
2353 (See the
2354 .B \-l
2355 option description for information on when a user ID number or
2356 login name is displayed.)
2357 .TP
2358 FD
2359 is the File Descriptor number of the file or:
2360 .IP
2361 .nf
2362         \fBcwd\fP       current working directory;
2363 .br
2364         \fBL\fInn\fR    library references (AIX);
2365 .br
2366         \fBerr\fR       FD information error (see NAME column);
2367 .br
2368         \fBjld\fR       jail directory (FreeBSD);
2369 .br
2370         \fBltx\fP       shared library text (code and data);
2371 .br
2372         \fBMxx\fP       hex memory\-mapped type number xx.
2373 .br
2374         \fBm86\fP       DOS Merge mapped file;
2375 .br
2376         \fBmem\fP       memory\-mapped file;
2377 .br
2378         \fBmmap\fP      memory\-mapped device;
2379 .br
2380         \fBpd\fP        parent directory;
2381 .br
2382         \fBrtd\fP       root directory;
2383 .br
2384         \fBtr\fR        kernel trace file (OpenBSD);
2385 .br
2386         \fBtxt\fP       program text (code and data);
2387 .br
2388         \fBv86\fP       VP/ix mapped file;
2389 .fi
2390 .IP
2391 FD is followed by one of these characters, describing the mode under which
2392 the file is open:
2393 .IP
2394         \fBr\fP for read access;
2395 .br
2396         \fBw\fP for write access;
2397 .br
2398         \fBu\fP for read and write access;
2399 .br
2400         space if mode unknown and no lock
2401 .br
2402                 character follows;
2403 .br
2404         `\-' if mode unknown and lock
2405 .br
2406                 character follows.
2407 .IP
2408 The mode character is followed by one of these lock characters, describing
2409 the type of lock applied to the file:
2410 .IP
2411         \fBN\fP for a Solaris NFS lock of unknown type;
2412 .br
2413         \fBr\fP for read lock on part of the file;
2414 .br
2415         \fBR\fP for a read lock on the entire file;
2416 .br
2417         \fBw\fP for a write lock on part of the file;
2418 .br
2419         \fBW\fP for a write lock on the entire file;
2420 .br
2421         \fBu\fP for a read and write lock of any length;
2422 .br
2423         \fBU\fP for a lock of unknown type;
2424 .br
2425         \fBx\fP for an SCO OpenServer Xenix lock on part
2426         of the file;
2427 .br
2428         \fBX\fP for an SCO OpenServer Xenix lock on the
2429         entire file;
2430 .br
2431         space if there is no lock.
2432 .IP
2433 See the
2434 .B LOCKS
2435 section for more information on the lock information character.
2436 .IP
2437 The FD column contents constitutes a single field for parsing in
2438 post\-processing scripts.
2439 .TP
2440 TYPE
2441 is the type of the node associated with the file \- e.g., GDIR, GREG,
2442 VDIR, VREG, etc.
2443 .IP
2444 or ``IPv4'' for an IPv4 socket;
2445 .IP
2446 or ``IPv6'' for an open IPv6 network file \- even if its address is
2447 IPv4, mapped in an IPv6 address;
2448 .IP
2449 or ``ax25'' for a Linux AX.25 socket;
2450 .IP
2451 or ``inet'' for an Internet domain socket;
2452 .IP
2453 or ``lla'' for a HP\-UX link level access file;
2454 .IP
2455 or ``rte'' for an AF_ROUTE socket;
2456 .IP
2457 or ``sock'' for a socket of unknown domain;
2458 .IP
2459 or ``unix'' for a UNIX domain socket;
2460 .IP
2461 or ``x.25'' for an HP\-UX x.25 socket;
2462 .IP
2463 or ``BLK'' for a block special file;
2464 .IP
2465 or ``CHR'' for a character special file;
2466 .IP
2467 or ``DEL'' for a Linux map file that has been deleted;
2468 .IP
2469 or ``DIR'' for a directory;
2470 .IP
2471 or ``DOOR'' for a VDOOR file;
2472 .IP
2473 or ``FIFO'' for a FIFO special file;
2474 .IP
2475 or ``KQUEUE'' for a BSD style kernel event queue file;
2476 .IP
2477 or ``LINK'' for a symbolic link file;
2478 .IP
2479 or ``MPB'' for a multiplexed block file;
2480 .IP
2481 or ``MPC'' for a multiplexed character file;
2482 .IP
2483 or ``NOFD'' for a Linux /proc/<PID>/fd directory that can't be opened \--
2484 the directory path appears in the NAME column, followed by an error
2485 message;
2486 .IP
2487 or ``PAS'' for a
2488 .I /proc/as
2489 file;
2490 .IP
2491 or ``PAXV'' for a
2492 .I /proc/auxv
2493 file;
2494 .IP
2495 or ``PCRE'' for a
2496 .I /proc/cred
2497 file;
2498 .IP
2499 or ``PCTL'' for a
2500 .I /proc
2501 control file;
2502 .IP
2503 or ``PCUR'' for the current
2504 .I /proc
2505 process;
2506 .IP
2507 or ``PCWD'' for a
2508 .I /proc
2509 current working directory;
2510 .IP
2511 or ``PDIR'' for a
2512 .I /proc
2513 directory;
2514 .IP
2515 or ``PETY'' for a
2516 .I /proc
2517 executable type (\fIetype\fP);
2518 .IP
2519 or ``PFD'' for a
2520 .I /proc
2521 file descriptor;
2522 .IP
2523 or ``PFDR'' for a
2524 .I /proc
2525 file descriptor directory;
2526 .IP
2527 or ``PFIL'' for an executable
2528 .I /proc
2529 file;
2530 .IP
2531 or ``PFPR'' for a
2532 .I /proc
2533 FP register set;
2534 .IP
2535 or ``PGD'' for a
2536 .I /proc/pagedata
2537 file;
2538 .IP
2539 or ``PGID'' for a
2540 .I /proc
2541 group notifier file;
2542 .IP
2543 or ``PIPE'' for pipes;
2544 .IP
2545 or ``PLC'' for a
2546 .I /proc/lwpctl
2547 file;
2548 .IP
2549 or ``PLDR'' for a
2550 .I /proc/lpw
2551 directory;
2552 .IP
2553 or ``PLDT'' for a
2554 .I /proc/ldt
2555 file;
2556 .IP
2557 or ``PLPI'' for a
2558 .I /proc/lpsinfo
2559 file;
2560 .IP
2561 or ``PLST'' for a
2562 .I /proc/lstatus
2563 file;
2564 .IP
2565 or ``PLU'' for a
2566 .I /proc/lusage
2567 file;
2568 .IP
2569 or ``PLWG'' for a
2570 .I /proc/gwindows
2571 file;
2572 .IP
2573 or ``PLWI'' for a
2574 .I /proc/lwpsinfo
2575 file;
2576 .IP
2577 or ``PLWS'' for a
2578 .I /proc/lwpstatus
2579 file;
2580 .IP
2581 or ``PLWU'' for a
2582 .I /proc/lwpusage
2583 file;
2584 .IP
2585 or ``PLWX'' for a
2586 .I /proc/xregs
2587 file'
2588 .IP
2589 or ``PMAP'' for a
2590 .I /proc
2591 map file (\fImap\fP);
2592 .IP
2593 or ``PMEM'' for a
2594 .I /proc
2595 memory image file;
2596 .IP
2597 or ``PNTF'' for a
2598 .I /proc
2599 process notifier file;
2600 .IP
2601 or ``POBJ'' for a
2602 .I /proc/object
2603 file;
2604 .IP
2605 or ``PODR'' for a
2606 .I /proc/object
2607 directory;
2608 .IP
2609 or ``POLP'' for an old format
2610 .I /proc
2611 light weight process file;
2612 .IP
2613 or ``POPF'' for an old format
2614 .I /proc
2615 PID file;
2616 .IP
2617 or ``POPG'' for an old format
2618 .I /proc
2619 page data file;
2620 .IP
2621 or ``PORT'' for a SYSV named pipe;
2622 .IP
2623 or ``PREG'' for a
2624 .I /proc
2625 register file;
2626 .IP
2627 or ``PRMP'' for a
2628 .I /proc/rmap
2629 file;
2630 .IP
2631 or ``PRTD'' for a
2632 .I /proc
2633 root directory;
2634 .IP
2635 or ``PSGA'' for a
2636 .I /proc/sigact
2637 file;
2638 .IP
2639 or ``PSIN'' for a
2640 .I /proc/psinfo
2641 file;
2642 .IP
2643 or ``PSTA'' for a
2644 .I /proc
2645 status file;
2646 .IP
2647 or ``PSXSEM'' for a POSIX semaphore file;
2648 .IP
2649 or ``PSXSHM'' for a POSIX shared memory file;
2650 .IP
2651 or ``PUSG'' for a
2652 .I /proc/usage
2653 file;
2654 .IP
2655 or ``PW'' for a
2656 .I /proc/watch
2657 file;
2658 .IP
2659 or ``PXMP'' for a
2660 .I /proc/xmap
2661 file;
2662 .IP
2663 or ``REG'' for a regular file;
2664 .IP
2665 or ``SMT'' for a shared memory transport file;
2666 .IP
2667 or ``STSO'' for a stream socket;
2668 .IP
2669 or ``UNNM'' for an unnamed type file;
2670 .IP
2671 or ``XNAM'' for an OpenServer Xenix special file of unknown type;
2672 .IP
2673 or ``XSEM'' for an OpenServer Xenix semaphore file;
2674 .IP
2675 or ``XSD'' for an OpenServer Xenix shared data file;
2676 .IP
2677 or the four type number octets if the corresponding name isn't known.
2678 .TP
2679 FILE\-ADDR
2680 contains the kernel file structure address when
2681 .B f
2682 has been specified to
2683 .BR +f ;
2684 .TP
2685 FCT
2686 contains the file reference count from the kernel file structure when
2687 .B c
2688 has been specified to
2689 .BR +f ;
2690 .TP
2691 FILE\-FLAG
2692 when
2693 .B g
2694 or
2695 .B G
2696 has been specified to
2697 .BR +f ,
2698 this field contains the contents of the f_flag[s] member of the kernel
2699 file structure and the kernel's per\-process open file flags (if available);
2700 \&`G' causes them to be displayed in hexadecimal;
2701 \&`g', as short\-hand names;
2702 two lists may be displayed with entries separated by commas, the
2703 lists separated by a semicolon (`;');
2704 the first list may contain short\-hand names for f_flag[s] values from
2705 the following table:
2706 .IP
2707 .nf
2708         AIO             asynchronous I/O (e.g., FAIO)
2709         AP              append
2710         ASYN            asynchronous I/O (e.g., FASYNC)
2711         BAS             block, test, and set in use
2712         BKIU            block if in use
2713         BL              use block offsets
2714         BSK             block seek
2715         CA              copy avoid
2716         CIO             concurrent I/O
2717         CLON            clone
2718         CLRD            CL read
2719         CR              create
2720         DF              defer
2721         DFI             defer IND
2722         DFLU            data flush
2723         DIR             direct
2724         DLY             delay
2725         DOCL            do clone
2726         DSYN            data\-only integrity
2727         DTY             must be a directory
2728         EVO             event only
2729         EX              open for exec
2730         EXCL            exclusive open
2731         FSYN            synchronous writes
2732         GCDF            defer during unp_gc() (AIX)
2733         GCMK            mark during unp_gc() (AIX)
2734         GTTY            accessed via /dev/tty
2735         HUP             HUP in progress
2736         KERN            kernel
2737         KIOC            kernel\-issued ioctl
2738         LCK             has lock
2739         LG              large file
2740         MBLK            stream message block
2741         MK              mark
2742         MNT             mount
2743         MSYN            multiplex synchronization
2744         NATM            don't update atime
2745         NB              non\-blocking I/O
2746         NBDR            no BDRM check
2747         NBIO            SYSV non\-blocking I/O
2748         NBF             n\-buffering in effect
2749         NC              no cache
2750         ND              no delay
2751         NDSY            no data synchronization
2752         NET             network
2753         NFLK            don't follow links
2754         NMFS            NM file system
2755         NOTO            disable background stop
2756         NSH             no share
2757         NTTY            no controlling TTY
2758         OLRM            OLR mirror
2759         PAIO            POSIX asynchronous I/O
2760         PP              POSIX pipe
2761         R               read
2762         RC              file and record locking cache
2763         REV             revoked
2764         RSH             shared read
2765         RSYN            read synchronization
2766         RW              read and write access
2767         SL              shared lock
2768         SNAP            cooked snapshot
2769         SOCK            socket
2770         SQSH            Sequent shared set on open
2771         SQSV            Sequent SVM set on open
2772         SQR             Sequent set repair on open
2773         SQS1            Sequent full shared open
2774         SQS2            Sequent partial shared open
2775         STPI            stop I/O
2776         SWR             synchronous read
2777         SYN             file integrity while writing
2778         TCPM            avoid TCP collision
2779         TR              truncate
2780         W               write
2781         WKUP            parallel I/O synchronization
2782         WTG             parallel I/O synchronization
2783         VH              vhangup pending
2784         VTXT            virtual text
2785         XL              exclusive lock
2786 .fi
2787 .IP
2788 this list of names was derived from F* #define's in dialect header files
2789 <fcntl.h>, <linux</fs.h>, <sys/fcntl.c>, <sys/fcntlcom.h>, and <sys/file.h>;
2790 see the lsof.h header file for a list showing the correspondence
2791 between the above short\-hand names and the header file definitions;
2792 .IP
2793 the second list (after the semicolon) may contain short\-hand names
2794 for kernel per\-process open file flags from this table:
2795 .IP
2796 .nf
2797         ALLC            allocated
2798         BR              the file has been read
2799         BHUP            activity stopped by SIGHUP
2800         BW              the file has been written
2801         CLSG            closing
2802         CX              close\-on-exec (see fcntl(F_SETFD))
2803         LCK             lock was applied
2804         MP              memory\-mapped
2805         OPIP            open pending \- in progress
2806         RSVW            reserved wait
2807         SHMT            UF_FSHMAT set (AIX)
2808         USE             in use (multi\-threaded)
2809 .fi
2810 .TP
2811 NODE\-ID
2812 (or INODE\-ADDR for some dialects)
2813 contains a unique identifier for the file node (usually the kernel
2814 vnode or inode address, but also occasionally a concatenation of
2815 device and node number) when
2816 .B n
2817 has been specified to
2818 .BR +f ;
2819 .TP
2820 DEVICE
2821 contains the device numbers, separated by commas, for a character special,
2822 block special, regular, directory or NFS file;
2823 .IP
2824 or ``memory'' for a memory file system node under Tru64 UNIX;
2825 .IP
2826 or the address of the private data area of a Solaris socket
2827 stream;
2828 .IP
2829 or a kernel reference address that identifies the file
2830 (The kernel reference address may be used for FIFO's, for example.);
2831 .IP
2832 or
2833 the base address or device name of a Linux AX.25 socket device.
2834 .IP
2835 Usually only the lower thirty two bits of Tru64 UNIX kernel addresses
2836 are displayed.
2837 .TP
2838 SIZE, SIZE/OFF, or OFFSET
2839 is the size of the file or the file offset in bytes.
2840 A value is displayed in this column only if it is available.
2841 .I Lsof
2842 displays whatever value \- size or offset \- is appropriate for the type
2843 of the file and the version of
2844 .IR lsof .
2845 .IP
2846 On some UNIX dialects
2847 .I lsof
2848 can't obtain accurate or consistent file offset information from its
2849 kernel data sources, sometimes just for particular kinds of files
2850 (e.g., socket files.)
2851 In other cases, files don't have true sizes \- e.g., sockets, FIFOs,
2852 pipes \- so
2853 .I lsof
2854 displays for their sizes the content amounts it finds in their kernel
2855 buffer descriptors (e.g., socket buffer size counts or TCP/IP window
2856 sizes.)
2857 Consult the
2858 .I lsof
2859 FAQ (The \fBFAQ\fP section gives its location.)
2860 for more information.
2861 .IP
2862 The file size is displayed in decimal;
2863 the offset is normally displayed in decimal with a leading ``0t'' if
2864 it contains 8 digits or less; in hexadecimal with a leading ``0x'' if
2865 it is longer than 8 digits.
2866 (Consult the
2867 .BI \-o " o"
2868 option description for information on when 8 might default to
2869 some other value.)
2870 .IP
2871 Thus the leading ``0t'' and ``0x'' identify an offset when the column
2872 may contain both a size and an offset (i.e., its title is SIZE/OFF).
2873 .IP
2874 If the
2875 .B \-o
2876 option is specified,
2877 .I lsof
2878 always displays the file offset (or nothing if no offset is available)
2879 and labels the column OFFSET.
2880 The offset always begins with ``0t'' or ``0x'' as described above.
2881 .IP
2882 The
2883 .I lsof
2884 user can control the switch from ``0t'' to ``0x'' with the
2885 .BI \-o " o"
2886 option.
2887 Consult its description for more information.
2888 .IP
2889 If the
2890 .B \-s
2891 option is specified,
2892 .I lsof
2893 always displays the file size (or nothing if no size is available)
2894 and labels the column SIZE.
2895 The
2896 .B \-o
2897 and
2898 .B \-s
2899 options are mutually exclusive; they can't both be specified.
2900 .IP
2901 For files that don't have a fixed size \- e.g., don't reside
2902 on a disk device \-
2903 .I lsof
2904 will display appropriate information about the current size or
2905 position of the file if it is available in the kernel structures
2906 that define the file.
2907 .TP
2908 NLINK
2909 contains the file link count when
2910 .B +L
2911 has been specified;
2912 .TP
2913 NODE
2914 is the node number of a local file;
2915 .IP
2916 or the inode number of an NFS file in the server host;
2917 .IP
2918 or the Internet protocol type \- e. g, ``TCP'';
2919 .IP
2920 or ``STR'' for a stream;
2921 .IP
2922 or ``CCITT'' for an HP\-UX x.25 socket;
2923 .IP
2924 or the IRQ or inode number of a Linux AX.25 socket device.
2925 .TP
2926 NAME
2927 is the name of the mount point and file system on which the file resides;
2928 .IP
2929 or the name of a file specified in the
2930 .I names
2931 option (after any symbolic links have been resolved);
2932 .IP
2933 or the name of a character special or block special device;
2934 .IP
2935 or the local and remote Internet addresses of a network file;
2936 the local host name or IP number is followed by a colon (':'), the
2937 port, ``->'', and the two\-part remote address;
2938 IP addresses may be reported as numbers or names, depending on the
2939 .BR +|\-M ,
2940 .BR \-n ,
2941 and
2942 .B \-P
2943 options;
2944 colon\-separated IPv6 numbers are enclosed in square brackets;
2945 IPv4 INADDR_ANY and IPv6 IN6_IS_ADDR_UNSPECIFIED addresses, and
2946 zero port numbers are represented by an asterisk ('*');
2947 a UDP destination address may be followed by the amount of time
2948 elapsed since the last packet was sent to the destination;
2949 TCP, UDP and UDPLITE remote addresses may be followed by TCP/TPI
2950 information in parentheses \- state (e.g., ``(ESTABLISHED)'', ``(Unbound)''),
2951 queue sizes, and window sizes (not all dialects) \- in a fashion
2952 similar to what
2953 .IR netstat (1)
2954 reports;
2955 see the
2956 .B \-T
2957 option description or the description of the TCP/TPI field in
2958 .B "OUTPUT FOR OTHER PROGRAMS"
2959 for more information on state, queue size, and window size;
2960 .IP
2961 or the address or name of a UNIX domain socket, possibly including
2962 a stream clone device name, a file system object's path name, local
2963 and foreign kernel addresses, socket pair information, and a bound
2964 vnode address;
2965 .IP
2966 or the local and remote mount point names of an NFS file;
2967 .IP
2968 or ``STR'', followed by the stream name;
2969 .IP
2970 or a stream character device name, followed by ``->'' and the stream name
2971 or a list of stream module names, separated by ``->'';
2972 .IP
2973 or ``STR:'' followed by the SCO OpenServer stream device and module
2974 names, separated by ``->'';
2975 .IP
2976 or system directory name, `` -- '', and as many components of the path
2977 name as
2978 .I lsof
2979 can find in the kernel's name cache for selected dialects
2980 (See the
2981 .B "KERNEL NAME CACHE"
2982 section for more information.);
2983 .IP
2984 or ``PIPE->'', followed by a Solaris kernel pipe destination address;
2985 .IP
2986 or ``COMMON:'', followed by the vnode device information structure's
2987 device name, for a Solaris common vnode;
2988 .IP
2989 or the address family, followed by a slash (`/'), followed by fourteen
2990 comma\-separated bytes of a non\-Internet raw socket address;
2991 .IP
2992 or the HP\-UX x.25 local address, followed by the virtual connection
2993 number (if any), followed by the remote address (if any);
2994 .IP
2995 or ``(dead)'' for disassociated Tru64 UNIX files \- typically terminal files
2996 that have been flagged with the TIOCNOTTY ioctl and closed by daemons;
2997 .IP
2998 or ``rd=<offset>'' and ``wr=<offset>'' for the values of the
2999 read and write offsets of a FIFO;
3000 .IP
3001 or ``clone \fIn\fP:/dev/event'' for SCO OpenServer file clones of the
3002 .I /dev/event
3003 device, where
3004 .I n
3005 is the minor device number of the file;
3006 .IP
3007 or ``(socketpair: n)'' for a Solaris 2.6, 8, 9  or 10
3008 UNIX domain socket, created by the
3009 .IR socketpair (3N)
3010 network function;
3011 .IP
3012 or ``no PCB'' for socket files that do not have a protocol block
3013 associated with them, optionally followed by ``, CANTSENDMORE'' if
3014 sending on the socket has been disabled, or ``, CANTRCVMORE'' if
3015 receiving on the socket has been disabled (e.g., by the
3016 .IR shutdown (2)
3017 function);
3018 .IP
3019 or the local and remote addresses of a Linux IPX socket file
3020 in the form <net>:[<node>:]<port>, followed in parentheses
3021 by the transmit and receive queue sizes, and the connection state;
3022 .IP
3023 or ``dgram'' or ``stream'' for the type UnixWare 7.1.1 and above in\-kernel
3024 UNIX domain sockets, followed by a colon (':') and the local path name
3025 when available, followed by ``->'' and the remote path name or kernel
3026 socket address in hexadecimal when available;
3027 .IP
3028 or the association value, association index, endpoint value, local address,
3029 local port, remote address and remote port for Linux SCTP sockets;
3030 .IP
3031 or ``protocol: '' followed by the Linux socket's protocol attribute.
3032 .PP
3033 For dialects that support a ``namefs'' file system, allowing one
3034 file to be attached to another with
3035 .IR fattach (3C),
3036 .I lsof
3037 will add ``(FA:<address1><direction><address2>)'' to the NAME column.
3038 <address1> and <address2> are hexadecimal vnode addresses.
3039 <direction> will be ``<-'' if <address2> has been fattach'ed to
3040 this vnode whose address is <address1>;
3041 and ``->'' if <address1>, the vnode address of this vnode, has been
3042 fattach'ed to <address2>.
3043 <address1> may be omitted if it already appears in the DEVICE column.
3044 .PP
3045 .I
3046 Lsof
3047 may add two parenthetical notes to the NAME column for open Solaris 10 files:
3048 \&``(?)'' if
3049 .I lsof
3050 considers the path name of questionable accuracy;
3051 and ``(deleted)'' if the
3052 .B \-X
3053 option has been specified and
3054 .I lsof
3055 detects the open file's path name has been deleted.
3056 Consult the
3057 .I lsof
3058 FAQ (The \fBFAQ\fP section gives its location.)
3059 for more information on these NAME column additions.
3060 .SH LOCKS
3061 .I Lsof
3062 can't adequately report the wide variety of UNIX dialect file locks
3063 in a single character.
3064 What it reports in a single character is a compromise between the
3065 information it finds in the kernel and the limitations of the reporting
3066 format.
3067 .PP
3068 Moreover, when a process holds several byte level locks on a file,
3069 .I lsof
3070 only reports the status of the first lock it encounters.
3071 If it is a byte level lock, then the lock character will be reported
3072 in lower case \- i.e., `r', `w', or `x' \- rather than the upper case
3073 equivalent reported for a full file lock.
3074 .PP
3075 Generally
3076 .I lsof
3077 can only report on locks held by local processes on local files.
3078 When a local process sets a lock on a remotely mounted (e.g., NFS)
3079 file, the remote server host usually records the lock state.
3080 One exception is Solaris \- at some patch levels of 2.3, and in all
3081 versions above 2.4, the Solaris kernel records information on remote
3082 locks in local structures.
3083 .PP
3084 .I Lsof
3085 has trouble reporting locks for some UNIX dialects.
3086 Consult the
3087 .B BUGS
3088 section of this manual page or the
3089 .I lsof
3090 FAQ (The \fBFAQ\fP section gives its location.)
3091 for more information.
3092 .SH "OUTPUT FOR OTHER PROGRAMS"
3093 When the
3094 .B \-F
3095 option is specified,
3096 .I lsof
3097 produces output that is suitable for processing by another program \- e.g, an
3098 .I awk
3099 or
3100 .I Perl
3101 script, or a C program.
3102 .PP
3103 Each unit of information is output in a field that is identified
3104 with a leading character and terminated by a NL (012) (or a NUL
3105 (000) if the 0 (zero) field identifier character is specified.)
3106 The data of the field follows immediately after the field identification
3107 character and extends to the field terminator.
3108 .PP
3109 It is possible to think of field output as process and file sets.
3110 A process set begins with a field whose identifier is `p' (for
3111 process IDentifier (PID)).
3112 It extends to the beginning of the next PID field or the beginning
3113 of the first file set of the process, whichever comes first.
3114 Included in the process set are fields that identify the command,
3115 the process group IDentification (PGID) number, the task (thread)
3116 ID (TID), and the user ID (UID) number or login name.
3117 .PP
3118 A file set begins with a field whose identifier is `f' (for
3119 file descriptor).
3120 It is followed by lines that describe the file's access mode,
3121 lock state, type, device, size, offset, inode, protocol, name
3122 and stream module names.
3123 It extends to the beginning of the next file or process set,
3124 whichever comes first.
3125 .PP
3126 When the NUL (000) field terminator has been selected with the
3127 0 (zero) field identifier character,
3128 .I lsof
3129 ends each process and file set with a NL (012) character.
3130 .PP
3131 .I Lsof
3132 always produces one field, the PID (`p') field.
3133 All other fields may be declared optionally in the field identifier
3134 character list that follows the
3135 .B \-F
3136 option.
3137 When a field selection character identifies an item
3138 .I lsof
3139 does not normally list \- e.g., PPID, selected with
3140 .BR \-R " \-"
3141 specification of the field character \- e.g., ``\fB\-FR\fP'' \-
3142 also selects the listing of the item.
3143 .PP
3144 It is entirely possible to select a set of fields that cannot
3145 easily be parsed \- e.g., if the field descriptor field is not
3146 selected, it may be difficult to identify file sets.
3147 To help you avoid this difficulty,
3148 .I lsof
3149 supports the
3150 .B \-F
3151 option; it selects the output of all fields with NL terminators
3152 (the
3153 .B \-F0
3154 option pair selects the output of all fields with NUL terminators).
3155 For compatibility reasons neither
3156 .B \-F
3157 nor
3158 .B \-F0
3159 select the raw device field.
3160 .PP
3161 These are the fields that
3162 .I lsof
3163 will produce.
3164 The single character listed first is the field identifier.
3165 .PP
3166 .nf
3167         a       file access mode
3168         c       process command name (all characters from proc or
3169                 user structure)
3170         C       file structure share count
3171         d       file's device character code 
3172         D       file's major/minor device number (0x<hexadecimal>)
3173         f       file descriptor (always selected)
3174         F       file structure address (0x<hexadecimal>)
3175         G       file flaGs (0x<hexadecimal>; names if \fB+fg\fP follows)
3176         g       process group ID
3177         i       file's inode number
3178         K       tasK ID
3179         k       link count
3180         l       file's lock status
3181         L       process login name
3182         m       marker between repeated output
3183         n       file name, comment, Internet address
3184         N       node identifier (ox<hexadecimal>
3185         o       file's offset (decimal)
3186         p       process ID (always selected)
3187         P       protocol name
3188         r       raw device number (0x<hexadecimal>)
3189         R       parent process ID
3190         s       file's size (decimal)
3191         S       file's stream identification
3192         t       file's type
3193         T       TCP/TPI information, identified by prefixes (the
3194                 `=' is part of the prefix):
3195                     QR=<read queue size>
3196                     QS=<send queue size>
3197                     SO=<socket options and values> (not all dialects)
3198                     SS=<socket states> (not all dialects)
3199                     ST=<connection state>
3200                     TF=<TCP flags and values> (not all dialects)
3201                     WR=<window read size>  (not all dialects)
3202                     WW=<window write size>  (not all dialects)
3203                 (TCP/TPI information isn't reported for all supported
3204                   UNIX dialects. The \fB\-h\fP or \fB\-?\fP help output for the
3205                   \fB\-T\fP option will show what TCP/TPI reporting can be
3206                   requested.)
3207         u       process user ID
3208         z       Solaris 10 and higher zone name
3209         Z       SELinux security context (inhibited when SELinux is disabled)
3210         0       use NUL field terminator character in place of NL
3211         1\-9    dialect\-specific field identifiers (The output
3212                 of \fB\-F?\fP identifies the information to be found
3213                 in dialect\-specific fields.)
3214 .fi
3215 .PP
3216 You can get on\-line help information on these characters and their
3217 descriptions by specifying the
3218 .B \-F?
3219 option pair.
3220 (Escape the `?' character as your shell requires.)
3221 Additional information on field content can be found in the
3222 .B OUTPUT
3223 section.
3224 .PP
3225 As an example, ``\fB\-F pcfn\fP'' will select the process ID (`p'),
3226 command name (`c'), file descriptor (`f') and file name (`n')
3227 fields with an NL field terminator character; ``\fB\-F pcfn0\fP''
3228 selects the same output with a NUL (000) field terminator character.
3229 .PP
3230 .I Lsof
3231 doesn't produce all fields for every process or file set, only
3232 those that are available.
3233 Some fields are mutually exclusive: file device characters and
3234 file major/minor device numbers; file inode number and protocol
3235 name; file name and stream identification; file size and offset.
3236 One or the other member of these mutually exclusive sets will appear
3237 in field output, but not both.
3238 .PP
3239 Normally
3240 .I lsof
3241 ends each field with a NL (012) character.
3242 The
3243 0 (zero) field identifier character may be specified to change the
3244 field terminator character
3245 to a NUL (000).
3246 A NUL terminator may be easier to process with
3247 .I xargs (1),
3248 for example, or with programs whose quoting mechanisms may not
3249 easily cope with the range of characters in the field output.
3250 When the NUL field terminator is in use,
3251 .I lsof
3252 ends each process and file set with a NL (012).
3253 .PP
3254 Three aids to producing programs that can process
3255 .I lsof
3256 field output are included in the
3257 .I lsof
3258 distribution.
3259 The first is a C header file,
3260 .IR lsof_fields.h ,
3261 that contains symbols for the field identification characters, indexes for
3262 storing them in a table, and explanation strings that may be compiled into
3263 programs.
3264 .I Lsof
3265 uses this header file.
3266 .PP
3267 The second aid is a set of sample scripts that process field output,
3268 written in
3269 .IR awk ,
3270 .I Perl
3271 4, and
3272 .I Perl
3273 5.
3274 They're located in the
3275 .I scripts
3276 subdirectory of the
3277 .I lsof
3278 distribution.
3279 .PP
3280 The third aid is the C library used for the
3281 .I lsof
3282 test suite.
3283 The test suite is written in C and uses field output to validate
3284 the correct operation of
3285 .IR lsof .
3286 The library can be found in the
3287 .I tests/LTlib.c
3288 file of the
3289 .I lsof
3290 distribution.
3291 The library uses the first aid, the
3292 .I lsof_fields.h
3293 header file.
3294 .SH "BLOCKS AND TIMEOUTS"
3295 .I Lsof
3296 can be blocked by some kernel functions that it uses \-
3297 .IR lstat (2),
3298 .IR readlink (2),
3299 and
3300 .IR stat (2).
3301 These functions are stalled in the kernel, for example, when the
3302 hosts where mounted NFS file systems reside become inaccessible.
3303 .PP
3304 .I Lsof
3305 attempts to break these blocks with timers and child processes,
3306 but the techniques are not wholly reliable.
3307 When
3308 .I lsof
3309 does manage to break a block, it will report the break with an error
3310 message.
3311 The messages may be suppressed with the
3312 .B \-t
3313 and
3314 .B \-w
3315 options.
3316 .PP
3317 The default timeout value may be displayed with the
3318 .B \-h
3319 or
3320 .B \-?
3321 option, and it may be changed with the
3322 .BI \-S " [t]"
3323 option.
3324 The minimum for
3325 .I t
3326 is two seconds, but you should avoid small values, since slow system
3327 responsiveness can cause short timeouts to expire unexpectedly and
3328 perhaps stop
3329 .I lsof
3330 before it can produce any output.
3331 .PP
3332 When
3333 .I lsof
3334 has to break a block during its access of mounted file system
3335 information, it normally continues, although with less information
3336 available to display about open files.
3337 .PP
3338 .I Lsof
3339 can also be directed to avoid the protection of timers and child processes
3340 when using the kernel functions that might block by specifying the
3341 .B \-O
3342 option.
3343 While this will allow
3344 .I lsof
3345 to start up with less overhead, it exposes
3346 .I lsof
3347 completely to the kernel situations that might block it.
3348 Use this option cautiously.
3349 .SH "AVOIDING KERNEL BLOCKS"
3350 .PP
3351 You can use the
3352 .B \-b
3353 option to tell
3354 .I lsof
3355 to avoid using kernel functions that would block.
3356 Some cautions apply.
3357 .PP
3358 First, using this option usually requires that your system supply
3359 alternate device numbers in place of the device numbers that
3360 .I lsof
3361 would normally obtain with the
3362 .IR lstat (2)
3363 and
3364 .IR stat (2)
3365 kernel functions.
3366 See the
3367 .B "ALTERNATE DEVICE NUMBERS"
3368 section for more information on alternate device numbers.
3369 .PP
3370 Second, you can't specify
3371 .I names
3372 for
3373 .I lsof
3374 to locate unless they're file system names.
3375 This is because
3376 .I lsof
3377 needs to know the device and inode numbers of files listed with
3378 .I names
3379 in the
3380 .I lsof
3381 options, and the
3382 .B \-b
3383 option prevents
3384 .I lsof
3385 from obtaining them.
3386 Moreover, since
3387 .I lsof
3388 only has device numbers for the file systems that have alternates,
3389 its ability to locate files on file systems depends completely on the
3390 availability and accuracy of the alternates.
3391 If no alternates are available, or if they're incorrect,
3392 .I lsof
3393 won't be able to locate files on the named file systems.
3394 .PP
3395 Third, if the names of your file system directories that
3396 .I lsof
3397 obtains from your system's mount table are symbolic links,
3398 .I lsof
3399 won't be able to resolve the links.
3400 This is because the
3401 .B \-b
3402 option causes
3403 .I lsof
3404 to avoid the kernel
3405 .IR readlink (2)
3406 function it uses to resolve symbolic links.
3407 .PP
3408 Finally, using the
3409 .B \-b
3410 option causes
3411 .I lsof
3412 to issue warning messages when it needs to use the kernel functions
3413 that the
3414 .B \-b
3415 option directs it to avoid.
3416 You can suppress these messages by specifying the
3417 .B \-w
3418 option, but if you do, you won't see the alternate device numbers
3419 reported in the warning messages.
3420 .SH "ALTERNATE DEVICE NUMBERS"
3421 .PP
3422 On some dialects, when
3423 .I lsof
3424 has to break a block because it can't get information about a
3425 mounted file system via the
3426 .IR lstat (2)
3427 and
3428 .IR stat (2)
3429 kernel functions, or because you specified the
3430 .B \-b
3431 option,
3432 .I lsof
3433 can obtain some of the information it needs \- the device number and
3434 possibly the file system type \- from the system mount table.
3435 When that is possible,
3436 .I lsof
3437 will report the device number it obtained.
3438 (You can suppress the report by specifying the
3439 .B \-w
3440 option.)
3441 .PP
3442 You can assist this process if your mount table is supported with an
3443 .I /etc/mtab
3444 or
3445 .I /etc/mnttab
3446 file that contains an options field by adding a ``dev=xxxx'' field for
3447 mount points that do not have one in their options strings.
3448 Note: you must be able to edit the file \- i.e., some mount tables
3449 like recent Solaris /etc/mnttab or Linux /proc/mounts are read\-only
3450 and can't be modified.
3451 .PP
3452 You may also be able to supply device numbers using the
3453 .B +m
3454 and
3455 .BI +m " m"
3456 options, provided they are supported by your dialect.
3457 Check the output of
3458 .I lsof's
3459 .B \-h
3460 or
3461 .B \-?
3462 options to see if the
3463 .B +m
3464 and
3465 .BI +m " m"
3466 options are available.
3467 .PP
3468 The ``xxxx'' portion of the field is the hexadecimal value
3469 of the file system's device number.
3470 (Consult the
3471 .I st_dev
3472 field of the output of the
3473 .IR lstat (2)
3474 and
3475 .IR stat (2)
3476 functions for the appropriate values for your file systems.)
3477 Here's an example from a Sun Solaris 2.6
3478 .I /etc/mnttab
3479 for a file system remotely mounted via NFS:
3480 .PP
3481 .nf
3482         nfs  ignore,noquota,dev=2a40001
3483 .fi
3484 .PP
3485 There's an advantage to having ``dev=xxxx'' entries in your mount
3486 table file, especially for file systems that are mounted from remote
3487 NFS servers.
3488 When a remote server crashes and you want to identify its users by running
3489 .I lsof
3490 on one of its clients,
3491 .I lsof
3492 probably won't be able to get output from the
3493 .IR lstat (2)
3494 and
3495 .IR stat (2)
3496 functions for the file system.
3497 If it can obtain the file system's device number from the mount table,
3498 it will be able to display the files open on the crashed NFS server.
3499 .PP
3500 Some dialects that do not use an ASCII
3501 .I /etc/mtab
3502 or
3503 .I /etc/mnttab
3504 file for the mount table may still provide an alternative device number
3505 in their internal mount tables.
3506 This includes AIX, Apple Darwin, FreeBSD, NetBSD, OpenBSD, and Tru64 UNIX.
3507 .I Lsof
3508 knows how to obtain the alternative device number for these dialects
3509 and uses it when its attempt to
3510 .IR lstat (2)
3511 or
3512 .IR stat (2)
3513 the file system is blocked.
3514 .PP
3515 If you're not sure your dialect supplies alternate device numbers
3516 for file systems from its mount table, use this
3517 .I lsof
3518 incantation to see if it reports any alternate device numbers:
3519 .PP
3520 .IP
3521 lsof -b
3522 .PP
3523 Look for standard error file warning messages that
3524 begin ``assuming "dev=xxxx" from ...''.
3525 .SH "KERNEL NAME CACHE"
3526 .PP
3527 .I Lsof
3528 is able to examine the kernel's name cache or use other kernel
3529 facilities (e.g., the ADVFS 4.x tag_to_path() function under
3530 Tru64 UNIX) on some dialects for most file system types,
3531 excluding AFS, and extract recently used path name components from it.
3532 (AFS file system path lookups don't use the kernel's name cache; some
3533 Solaris VxFS file system operations apparently don't use it, either.)
3534 .PP
3535 .I Lsof
3536 reports the complete paths it finds in the NAME column.
3537 If
3538 .I lsof
3539 can't report all components in a path, it reports in the NAME column
3540 the file system name, followed by a space, two `-' characters, another
3541 space, and the name components it has located, separated by
3542 the `/' character.
3543 .PP
3544 When
3545 .I lsof
3546 is run in repeat mode \- i.e., with the
3547 .B \-r
3548 option specified \- the extent to which it can report path name
3549 components for the same file may vary from cycle to cycle.
3550 That's because other running processes can cause the kernel to
3551 remove entries from its name cache and replace them with others.
3552 .PP
3553 .I Lsof's
3554 use of the kernel name cache to identify the paths of files
3555 can lead it to report incorrect components under some circumstances.
3556 This can happen when the kernel name cache uses device and node
3557 number as a key (e.g., SCO OpenServer) and a key on a rapidly
3558 changing file system is reused.
3559 If the UNIX dialect's kernel doesn't purge the name cache entry for
3560 a file when it is unlinked,
3561 .I lsof
3562 may find a reference to the wrong entry in the cache.
3563 The
3564 .I lsof
3565 FAQ (The \fBFAQ\fP section gives its location.)
3566 has more information on this situation.
3567 .PP
3568 .I Lsof
3569 can report path name components for these dialects:
3570 .PP
3571 .nf
3572         FreeBSD
3573         HP\-UX
3574         Linux
3575         NetBSD
3576         NEXTSTEP
3577         OpenBSD
3578         OPENSTEP
3579         SCO OpenServer
3580         SCO|Caldera UnixWare
3581         Solaris
3582         Tru64 UNIX
3583 .fi
3584 .PP
3585 .I Lsof
3586 can't report path name components for these dialects:
3587 .PP
3588 .nf
3589         AIX
3590 .fi
3591 .PP
3592 If you want to know why
3593 .I lsof
3594 can't report path name components for some dialects, see the
3595 .I lsof
3596 FAQ (The \fBFAQ\fP section gives its location.)
3597 .SH "DEVICE CACHE FILE"
3598 .PP
3599 Examining all members of the
3600 .I /dev
3601 (or
3602 .IR /devices )
3603 node tree with
3604 .IR stat (2)
3605 functions can be time consuming.
3606 What's more, the information that
3607 .I lsof
3608 needs \- device number, inode number, and path \- rarely changes.
3609 .PP
3610 Consequently,
3611 .I lsof
3612 normally maintains an ASCII text file of cached
3613 .I /dev
3614 (or
3615 .IR /devices )
3616 information (exception: the /proc\-based Linux
3617 .I lsof
3618 where it's not needed.)
3619 The local system administrator who builds
3620 .I lsof
3621 can control the way the device cache file path is formed, selecting
3622 from these options:
3623 .PP
3624 .nf
3625         Path from the \fB\-D\fP option;
3626         Path from an environment variable;
3627         System\-wide path;
3628         Personal path (the default);
3629         Personal path, modified by an environment variable.
3630 .fi
3631 .PP
3632 Consult the output of the
3633 .BR \-h ,
3634 .B \-D? ,
3635 or
3636 .B \-?
3637 help options for the current state of device cache support.
3638 The help output lists the default read\-mode device cache file path that
3639 is in effect for the current invocation of
3640 .IR lsof .
3641 The
3642 .B \-D?
3643 option output lists the read\-only and write device cache file paths,
3644 the names of any applicable environment variables, and the personal
3645 device cache path format.
3646 .PP
3647 .I Lsof
3648 can detect that the current device cache file has been accidentally
3649 or maliciously modified by integrity checks, including the computation
3650 and verification of a sixteen bit Cyclic Redundancy Check (CRC) sum on
3651 the file's contents.
3652 When
3653 .I lsof
3654 senses something wrong with the file, it issues a warning and attempts
3655 to remove the current cache file and create a new copy, but only to
3656 a path that the process can legitimately write.
3657 .PP
3658 The path from which a
3659 .I lsof
3660 process may attempt to read a device cache file may not be the same
3661 as the path to which it can legitimately write.
3662 Thus when
3663 .I lsof
3664 senses that it needs to update the device cache file, it may
3665 choose a different path for writing it from the path from which
3666 it read an incorrect or outdated version.
3667 .PP
3668 If available, the
3669 .B \-Dr
3670 option will inhibit the writing of a new device cache file.
3671 (It's always available when specified without a path name argument.)
3672 .PP
3673 When a new device is added to the system, the device cache file may
3674 need to be recreated.
3675 Since
3676 .I lsof
3677 compares the mtime of the device cache file with the mtime and ctime
3678 of the
3679 .I /dev
3680 (or
3681 .IR /devices )
3682 directory, it usually detects that a new device has been added;
3683 in that case
3684 .I lsof
3685 issues a warning message and attempts to rebuild the device cache file.
3686 .PP
3687 Whenever
3688 .I lsof
3689 writes a device cache file, it sets its ownership to the real UID
3690 of the executing process, and its permission modes to 0600, this
3691 restricting its reading and writing to the file's owner.
3692 .SH "LSOF PERMISSIONS THAT AFFECT DEVICE CACHE FILE ACCESS"
3693 .PP
3694 Two permissions of the
3695 .I lsof
3696 executable affect its ability to access device cache files.
3697 The permissions are set by the local system administrator when
3698 .I lsof
3699 is installed.
3700 .PP
3701 The first and rarer permission is setuid\-root.
3702 It comes into effect when
3703 .I lsof
3704 is executed; its effective UID is then
3705 root, while its real (i.e., that of the logged\-on user) UID is not.
3706 The
3707 .I lsof
3708 distribution recommends that versions for these dialects run setuid\-root.
3709 .PP
3710 .nf
3711         HP-UX 11.11 and 11.23
3712         Linux
3713 .fi
3714 .PP
3715 The second and more common permission is setgid.
3716 It comes into effect when the effective group IDentification number (GID)
3717 of the
3718 .I lsof
3719 process is set to one that can access kernel memory devices \-
3720 e.g., ``kmem'', ``sys'', or ``system''.
3721 .PP
3722 An
3723 .I lsof
3724 process that has setgid permission usually surrenders the permission
3725 after it has accessed the kernel memory devices.
3726 When it does that,
3727 .I lsof
3728 can allow more liberal device cache path formations.
3729 The
3730 .I lsof
3731 distribution recommends that versions for these dialects run setgid
3732 and be allowed to surrender setgid permission.
3733 .PP
3734 .nf
3735         AIX 5.[12] and 5.3-ML1
3736         Apple Darwin 7.x Power Macintosh systems
3737         FreeBSD 4.x, 4.1x, 5.x and [6789].x for x86-based systems
3738         FreeBSD 5.x and [6789].x for Alpha, AMD64 and Sparc64-based
3739             systems
3740         HP\-UX 11.00 
3741         NetBSD 1.[456], 2.x and 3.x for Alpha, x86, and SPARC-based
3742             systems
3743         NEXTSTEP 3.[13] for NEXTSTEP architectures
3744         OpenBSD 2.[89] and 3.[0\-9] for x86-based systems
3745         OPENSTEP 4.x
3746         SCO OpenServer Release 5.0.6 for x86-based systems
3747         SCO|Caldera UnixWare 7.1.4 for x86-based systems
3748         Solaris 2.6, 8, 9 and 10
3749         Tru64 UNIX 5.1
3750 .fi
3751 .PP
3752 (Note:
3753 .I lsof
3754 for AIX 5L and above needs setuid\-root permission if its
3755 .B \-X
3756 option is used.)
3757 .PP
3758 .I Lsof
3759 for these dialects does not support a device cache, so the permissions
3760 given to the executable don't apply to the device cache file.
3761 .PP
3762 .nf
3763         Linux
3764 .fi
3765 .SH "DEVICE CACHE FILE PATH FROM THE \-D OPTION"
3766 .PP
3767 The
3768 .B \-D
3769 option provides limited means for specifying the device cache file path.
3770 Its
3771 .B ?
3772 function will report the read\-only and write device cache file paths that
3773 .I lsof
3774 will use.
3775 .PP
3776 When the
3777 .B \-D
3778 .BR b ,
3779 .BR r ,
3780 and
3781 .B u
3782 functions are available, you can use them to request that the cache file be
3783 built in a specific location (\fBb\fR[\fIpath\fR]);
3784 read but not rebuilt (\fBr\fR[\fIpath\fR]);
3785 or read and rebuilt (\fBu\fR[\fIpath\fR]).
3786 The
3787 .BR b ,
3788 .BR r ,
3789 and
3790 .B u
3791 functions are restricted under some conditions.
3792 They are restricted when the
3793 .I lsof
3794 process is setuid\-root.
3795 The path specified with the
3796 .B r
3797 function is always read\-only, even
3798 when it is available.
3799 .PP
3800 The
3801 .BR b ,
3802 .BR r ,
3803 and
3804 .B u
3805 functions are also restricted when the
3806 .I lsof
3807 process runs setgid and
3808 .I lsof
3809 doesn't surrender the setgid permission.
3810 (See the
3811 .B "LSOF PERMISSIONS THAT AFFECT DEVICE CACHE FILE ACCESS"
3812 section for a list of implementations that normally don't surrender
3813 their setgid permission.)
3814 .PP
3815 A further
3816 .B \-D
3817 function,
3818 .B i
3819 (for ignore), is always available.
3820 .PP
3821 When available, the
3822 .B b
3823 function tells
3824 .I lsof
3825 to read device information from the kernel with the
3826 .IR stat (2)
3827 function and build a device cache file at the indicated path.
3828 .PP
3829 When available, the
3830 .B r
3831 function tells
3832 .I lsof
3833 to read the device cache file, but not update it.
3834 When a path argument accompanies
3835 .BR \-Dr ,
3836 it names the device cache file path.
3837 The
3838 .B r
3839 function is always available when it is specified without a
3840 path name argument.
3841 If
3842 .I lsof
3843 is not running setuid\-root and surrenders its setgid permission,
3844 a path name argument may accompany the
3845 .B r
3846 function.
3847 .PP
3848 When available, the
3849 .B u
3850 function tells
3851 .I lsof
3852 to attempt to read and use the device cache file.
3853 If it can't read the file, or if it finds the contents of the
3854 file incorrect or outdated, it will read information from the kernel,
3855 and attempt to write an updated version of the device cache file,
3856 but only to a path it considers legitimate for the
3857 .I lsof
3858 process effective and real UIDs.
3859 .SH "DEVICE CACHE PATH FROM AN ENVIRONMENT VARIABLE"
3860 .PP
3861 .I Lsof's
3862 second choice for the device cache file is the contents of the
3863 LSOFDEVCACHE environment variable.
3864 It avoids this choice if the
3865 .I lsof
3866 process is setuid\-root, or the real UID of the process is root.
3867 .PP
3868 A further restriction applies to a device cache file path taken from
3869 the LSOFDEVCACHE environment variable:
3870 .I lsof
3871 will not write a device cache file to the path if the
3872 .I lsof
3873 process doesn't surrender its setgid permission.
3874 (See the
3875 .B "LSOF PERMISSIONS THAT AFFECT DEVICE CACHE FILE ACCESS"
3876 section for information on implementations that don't surrender
3877 their setgid permission.)
3878 .PP
3879 The local system administrator can disable the use of the LSOFDEVCACHE
3880 environment variable or change its name when building
3881 .IR lsof .
3882 Consult the output of
3883 .B \-D?
3884 for the environment variable's name.
3885 .SH "SYSTEM-WIDE DEVICE CACHE PATH"
3886 .PP
3887 The local system administrator may choose to have a system\-wide
3888 device cache file when building
3889 .IR lsof .
3890 That file will generally be constructed by a special system administration
3891 procedure when the system is booted or when the contents of
3892 .I /dev
3893 or
3894 .IR /devices )
3895 changes.
3896 If defined, it is
3897 .I lsof's
3898 third device cache file path choice.
3899 .PP
3900 You can tell that a system\-wide device cache file is in effect
3901 for your local installation by examining the
3902 .I lsof
3903 help option output \- i.e., the output from the
3904 .B \-h
3905 or
3906 .B \-?
3907 option.
3908 .PP
3909 .I Lsof
3910 will never write to the system\-wide device cache file path by
3911 default.
3912 It must be explicitly named with a
3913 .B \-D
3914 function in a root\-owned procedure.
3915 Once the file has been written, the procedure must change its permission
3916 modes to 0644 (owner\-read and owner\-write, group\-read, and other\-read).
3917 .SH "PERSONAL DEVICE CACHE PATH (DEFAULT)"
3918 .PP
3919 The default device cache file path of the
3920 .I lsof
3921 distribution is one recorded in the home directory of the real UID
3922 that executes
3923 .IR lsof .
3924 Added to the home directory is a second path component of the form
3925 .IR .lsof_hostname .
3926 .PP
3927 This is
3928 .I lsof's
3929 fourth device cache file path choice, and is
3930 usually the default.
3931 If a system\-wide device cache file path was defined when
3932 .I lsof
3933 was built,
3934 this fourth choice will be applied when
3935 .I lsof
3936 can't find the system\-wide device cache file.
3937 This is the
3938 .B only
3939 time
3940 .I lsof
3941 uses two paths when reading the device cache file.
3942 .PP
3943 The
3944 .I hostname
3945 part of the second component is the base
3946 name of the executing host, as returned by
3947 .IR gethostname (2).
3948 The base name is defined to be the characters preceding the first `.'
3949 in the
3950 .IR gethostname (2)
3951 output, or all the
3952 .IR gethostname (2)
3953 output if it contains no `.'.
3954 .PP
3955 The device cache file belongs to the user ID and is readable and
3956 writable by the user ID alone \- i.e., its modes are 0600.
3957 Each distinct real user ID on a given host that executes
3958 .I lsof
3959 has a distinct device cache file.
3960 The
3961 .I hostname
3962 part of the path distinguishes device cache files in an NFS\-mounted
3963 home directory into which device cache files are written from
3964 several different hosts.
3965 .PP
3966 The personal device cache file path formed by this method represents
3967 a device cache file that
3968 .I lsof
3969 will attempt to read, and will attempt to write should it not
3970 exist or should its contents be incorrect or outdated.
3971 .PP
3972 The
3973 .B \-Dr
3974 option without a path name argument will inhibit the writing of a new
3975 device cache file.
3976 .PP
3977 The
3978 .B \-D?
3979 option will list the format specification for constructing the
3980 personal device cache file.
3981 The conversions used in the format specification are described in the
3982 .I 00DCACHE
3983 file of the
3984 .I lsof
3985 distribution.
3986 .SH "MODIFIED PERSONAL DEVICE CACHE PATH"
3987 .PP
3988 If this option is defined by the local system administrator when
3989 .I lsof
3990 is built, the LSOFPERSDCPATH environment variable contents may
3991 be used to add a component of the personal device cache file path.
3992 .PP
3993 The LSOFPERSDCPATH variable contents are inserted in the path at the
3994 place marked by the local system administrator with the ``%p''
3995 conversion in the HASPERSDC format specification of the dialect's
3996 .I machine.h 
3997 header file.
3998 (It's placed right after the home directory in the default
3999 .I lsof
4000 distribution.)
4001 .PP
4002 Thus, for example, if LSOFPERSDCPATH contains ``LSOF'', the home
4003 directory is ``/Homes/abe'', the host name is ``lsof.itap.purdue.edu'',
4004 and the HASPERSDC format is the default (``%h/%p.lsof_%L''), the
4005 modified personal device cache file path is:
4006 .PP
4007 .nf
4008         /Homes/abe/LSOF/.lsof_vic
4009 .fi
4010 .PP
4011 The LSOFPERSDCPATH environment variable is ignored when the
4012 .I lsof
4013 process is setuid\-root or when the real UID of the process is root.
4014 .PP
4015 .I Lsof
4016 will not write to a modified personal device cache file path if the
4017 .I lsof
4018 process doesn't surrender setgid permission.
4019 (See the
4020 .B "LSOF PERMISSIONS THAT AFFECT DEVICE CACHE FILE ACCESS"
4021 section for a list of implementations that normally don't surrender
4022 their setgid permission.)
4023 .PP
4024 If, for example, you want to create a sub\-directory of personal
4025 device cache file paths by using the LSOFPERSDCPATH environment
4026 variable to name it, and
4027 .I lsof
4028 doesn't surrender its setgid permission, you will have to allow
4029 .I lsof
4030 to create device cache files at the standard personal path and
4031 move them to your subdirectory with shell commands.
4032 .PP
4033 The local system administrator may: disable this option when
4034 .I lsof
4035 is built; change the name of the environment variable from
4036 LSOFPERSDCPATH to something else; change the HASPERSDC
4037 format to include the personal path component in another place;
4038 or exclude the personal path component entirely.
4039 Consult the output of the
4040 .B \-D?
4041 option for the environment variable's name and the HASPERSDC
4042 format specification.
4043 .SH DIAGNOSTICS
4044 Errors are identified with messages on the standard error file.
4045 .PP
4046 .I Lsof
4047 returns a one (1) if any error was detected, including the failure to
4048 locate command names, file names, Internet addresses or files, login
4049 names, NFS files, PIDs, PGIDs, or UIDs it was asked to list.
4050 If the
4051 .B \-V
4052 option is specified,
4053 .I lsof
4054 will indicate the search items it failed to list.
4055 .PP
4056 It returns a zero (0) if no errors were detected and if it was able to
4057 list some information about all the specified search arguments.
4058 .PP
4059 .PP
4060 When
4061 .I lsof
4062 cannot open access to
4063 .I /dev
4064 (or
4065 .IR /devices )
4066 or one of its subdirectories, or get information on a file in them with
4067 .IR stat (2),
4068 it issues a warning message and continues.
4069 That
4070 .I lsof
4071 will issue warning messages about inaccessible files in
4072 .I /dev
4073 (or
4074 .IR /devices )
4075 is indicated in its help output \- requested with the
4076 .B \-h
4077 or
4078 >B \-?
4079 options \-  with the message:
4080 .PP
4081 .nf
4082         Inaccessible /dev warnings are enabled.
4083 .fi
4084 .PP
4085 The warning message may be suppressed with the
4086 .B \-w
4087 option.
4088 It may also have been suppressed by the system administrator when
4089 .I lsof
4090 was compiled by the setting of the WARNDEVACCESS definition.
4091 In this case, the output from the help options will include the message:
4092 .PP
4093 .nf
4094         Inaccessible /dev warnings are disabled.
4095 .fi
4096 .PP
4097 Inaccessible device warning messages usually disappear after
4098 .I lsof
4099 has created a working device cache file.
4100 .SH EXAMPLES
4101 For a more extensive set of examples, documented more fully, see the
4102 .I 00QUICKSTART
4103 file of the
4104 .I lsof
4105 distribution.
4106 .PP
4107 To list all open files, use:
4108 .IP
4109 lsof
4110 .PP
4111 To list all open Internet, x.25 (HP\-UX), and UNIX domain files, use:
4112 .IP
4113 lsof -i -U
4114 .PP
4115 To list all open IPv4 network files in use by the process whose PID is
4116 1234, use:
4117 .IP
4118 lsof -i 4 -a -p 1234
4119 .PP
4120 Presuming the UNIX dialect supports IPv6, to list only open IPv6
4121 network files, use:
4122 .IP
4123 lsof -i 6
4124 .PP
4125 To list all files using any protocol on ports 513, 514, or 515 of host
4126 wonderland.cc.purdue.edu, use:
4127 .IP
4128 lsof -i @wonderland.cc.purdue.edu:513-515
4129 .PP
4130 To list all files using any protocol on any port of mace.cc.purdue.edu
4131 (cc.purdue.edu is the default domain), use:
4132 .IP
4133 lsof -i @mace
4134 .PP
4135 To list all open files for login name ``abe'', or user ID 1234, or
4136 process 456, or process 123, or process 789, use:
4137 .IP
4138 lsof -p 456,123,789 -u 1234,abe
4139 .PP
4140 To list all open files on device /dev/hd4, use:
4141 .IP
4142 lsof /dev/hd4
4143 .PP
4144 To find the process that has /u/abe/foo open, use:
4145 .IP
4146 lsof /u/abe/foo
4147 .PP
4148 To send a SIGHUP to the processes that have /u/abe/bar open, use:
4149 .IP
4150 kill -HUP `lsof -t /u/abe/bar`
4151 .PP
4152 To find any open file, including an open UNIX domain socket file,
4153 with the name
4154 .IR /dev/log ,
4155 use:
4156 .IP
4157 lsof /dev/log
4158 .PP
4159 To find processes with open files on the NFS file system named
4160 .I /nfs/mount/point
4161 whose server is inaccessible, and presuming your mount table supplies
4162 the device number for
4163 .IR /nfs/mount/point ,
4164 use:
4165 .IP
4166 lsof -b /nfs/mount/point
4167 .PP
4168 To do the preceding search with warning messages suppressed, use:
4169 .IP
4170 lsof -bw /nfs/mount/point
4171 .PP
4172 To ignore the device cache file, use:
4173 .IP
4174 lsof -Di
4175 .PP
4176 To obtain PID and command name field output for each process, file
4177 descriptor, file device number, and file inode number for each file
4178 of each process, use:
4179 .IP
4180 lsof -FpcfDi
4181 .PP
4182 To list the files at descriptors 1 and 3 of every process running the
4183 .I lsof
4184 command for login ID ``abe'' every 10 seconds, use:
4185 .IP
4186 lsof -c lsof -a -d 1 -d 3 -u abe -r10
4187 .PP
4188 To list the current working directory of processes running a command that
4189 is exactly four characters long and has an 'o' or 'O' in character three,
4190 use this regular expression form of the
4191 .BI \-c " c"
4192 option:
4193 .IP
4194 lsof -c /^..o.$/i -a -d cwd
4195 .PP
4196 To find an IP version 4 socket file by its associated numeric dot\-form
4197 address, use:
4198 .IP
4199 lsof -i@128.210.15.17
4200 .PP
4201 To find an IP version 6 socket file (when the UNIX dialect supports
4202 IPv6) by its associated numeric colon\-form address, use:
4203 .IP
4204 lsof -i@[0:1:2:3:4:5:6:7]
4205 .PP
4206 To find an IP version 6 socket file (when the UNIX dialect supports
4207 IPv6) by an associated numeric colon\-form address that has a run of
4208 zeroes in it \- e.g., the loop\-back address \- use:
4209 .IP
4210 lsof -i@[::1]
4211 .PP
4212 To obtain a repeat mode marker line that contains the current time, use:
4213 .IP
4214 lsof -rm====%T====
4215 .PP
4216 To add spaces to the previous marker line, use:
4217 .IP
4218 lsof -r "m==== %T ===="
4219 .SH BUGS
4220 Since
4221 .I lsof
4222 reads kernel memory in its search for open files, rapid changes in kernel
4223 memory may produce unpredictable results.
4224 .PP
4225 When a file has multiple record locks, the lock status character
4226 (following the file descriptor) is derived from a test of the first
4227 lock structure, not from any combination of the individual record
4228 locks that might be described by multiple lock structures.
4229 .PP
4230 .I Lsof
4231 can't search for files with restrictive access permissions by
4232 .I name
4233 unless it is installed with root set\-UID permission.
4234 Otherwise it is limited to searching for files to which its user
4235 or its set-GID group (if any) has access permission.
4236 .PP
4237 The display of the destination address of a raw socket (e.g., for
4238 .IR ping )
4239 depends on the UNIX operating system.
4240 Some dialects store the destination address in the raw socket's protocol
4241 control block, some do not.
4242 .PP
4243 .I Lsof
4244 can't always represent Solaris device numbers in the same way that
4245 .IR ls (1)
4246 does.
4247 For example, the major and minor device numbers that the
4248 .IR lstat (2)
4249 and
4250 .IR stat (2)
4251 functions report for the directory on which CD-ROM files are mounted
4252 (typically 
4253 .IR /cdrom )
4254 are not the same as the ones that it reports for the device on which
4255 CD-ROM files are mounted (typically
4256 .IR /dev/sr0 ).
4257 (\fILsof\fP reports the directory numbers.)
4258 .PP
4259 The support for
4260 .I /proc
4261 file systems is available only for BSD and Tru64 UNIX dialects, Linux, and
4262 dialects derived from SYSV R4 \- e.g., FreeBSD, NetBSD, OpenBSD, Solaris,
4263 UnixWare.
4264 .PP
4265 Some
4266 .I /proc
4267 file items \- device number, inode number, and file size \-
4268 are unavailable in some dialects.
4269 Searching for files in a
4270 .I /proc
4271 file system may require that the full path name be specified.
4272 .PP
4273 No text (\fBtxt\fP) file descriptors are displayed for Linux
4274 processes.
4275 All entries for files other than the current working directory,
4276 the root directory, and numerical file descriptors are labeled
4277 .B mem
4278 descriptors.
4279 .PP
4280 .I Lsof
4281 can't search for Tru64 UNIX named pipes by name, because their kernel
4282 implementation of lstat(2) returns an improper device number for a
4283 named pipe.
4284 .PP
4285 .I Lsof
4286 can't report fully or correctly on HP\-UX 9.01, 10.20, and 11.00 locks
4287 because of insufficient access to kernel data or errors in the
4288 kernel data.
4289 See the
4290 .I lsof
4291 FAQ (The \fBFAQ\fP section gives its location.)
4292 for details.
4293 .PP
4294 The AIX SMT file type is a fabrication.
4295 It's made up for file structures whose type (15) isn't defined in the AIX
4296 .I /usr/include/sys/file.h
4297 header file.
4298 One way to create such file structures is to run X clients with the DISPLAY
4299 variable set to ``:0.0''.
4300 .PP
4301 The
4302 .BI +|\-f [cfgGn]
4303 option is not supported under /proc\-based Linux
4304 .IR lsof ,
4305 because it doesn't read kernel structures from kernel memory.
4306 .SH ENVIRONMENT
4307 .I Lsof
4308 may access these environment variables.
4309 .TP \w'LSOFPERSDCPATH'u+4
4310 LANG
4311 defines a language locale.
4312 See
4313 .IR setlocale (3)
4314 for the names of other variables that can be used in place
4315 of LANG \- e.g., LC_ALL, LC_TYPE, etc.
4316 .TP
4317 LSOFDEVCACHE
4318 defines the path to a device cache file.
4319 See the
4320 .B "DEVICE CACHE PATH FROM AN ENVIRONMENT VARIABLE"
4321 section for more information.
4322 .TP
4323 LSOFPERSDCPATH
4324 defines the middle component of a modified personal device cache
4325 file path.
4326 See the
4327 .B "MODIFIED PERSONAL DEVICE CACHE PATH"
4328 section for more information.
4329 .SH FAQ
4330 Frequently-asked questions and their answers (an FAQ) are
4331 available in the
4332 .I 00FAQ
4333 file of the
4334 .I lsof
4335 distribution.
4336 .PP
4337 That file is also available via anonymous ftp from
4338 .I lsof.itap.purdue.edu
4339 at
4340 .IR pub/tools/unix/lsof FAQ .
4341 The URL is:
4342 .IP
4343 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/FAQ
4344 .SH FILES
4345 .TP \w'.lsof_hostname'u+4
4346 .I /dev/kmem
4347 kernel virtual memory device
4348 .TP
4349 .I /dev/mem
4350 physical memory device
4351 .TP
4352 .I /dev/swap
4353 system paging device
4354 .TP
4355 .I .lsof_hostname
4356 .I lsof's
4357 device cache file
4358 (The suffix,
4359 .IR hostname ,
4360 is the first component of the host's name returned by
4361 .IR gethostname (2) .)
4362 .SH AUTHORS
4363 .I Lsof
4364 was written by Victor A. Abell <abe@purdue.edu> of Purdue University.
4365 Many others have contributed to
4366 .IR lsof .
4367 They're listed in the
4368 .I 00CREDITS
4369 file of the
4370 .I lsof
4371 distribution.
4372 .SH DISTRIBUTION
4373 The latest distribution of
4374 .I lsof
4375 is available via anonymous ftp from the host
4376 .IR lsof.itap.purdue.edu .
4377 You'll find the
4378 .I lsof
4379 distribution in the
4380 .I pub/tools/unix/lsof
4381 directory.
4382 .PP
4383 You can also use this URL:
4384 .IP
4385 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof
4386 .PP
4387 .I Lsof
4388 is also mirrored elsewhere.
4389 When you access
4390 .I lsof.itap.purdue.edu
4391 and change to its
4392 .I pub/tools/unix/lsof
4393 directory, you'll be given a list of some mirror sites.
4394 The
4395 .I pub/tools/unix/lsof
4396 directory also contains a more complete list in its
4397 .I mirrors
4398 file.
4399 Use mirrors with caution \- not all mirrors always have the latest
4400 .I lsof
4401 revision.
4402 .PP
4403 Some pre\-compiled
4404 .I Lsof
4405 executables are available on
4406 .IR lsof.itap.purdue.edu ,
4407 but their use is discouraged \- it's better that you build
4408 your own from the sources.
4409 If you feel you must use a pre\-compiled executable, please
4410 read the cautions that appear in the README files of the
4411 .I pub/tools/unix/lsof/binaries
4412 subdirectories and in the 00* files of the distribution.
4413 .PP
4414 More information on the
4415 .I lsof
4416 distribution can be found in its
4417 .I README.lsof_<version>
4418 file.
4419 If you intend to get the
4420 .I lsof
4421 distribution and build it, please read
4422 .I README.lsof_<version>
4423 and the other 00* files of the distribution before sending questions
4424 to the author.
4425 .SH SEE ALSO
4426 .PP
4427 Not all the following manual pages may exist in every UNIX
4428 dialect to which
4429 .I lsof
4430 has been ported.
4431 .PP
4432 access(2),
4433 awk(1),
4434 crash(1),
4435 fattach(3C),
4436 ff(1),
4437 fstat(8),
4438 fuser(1),
4439 gethostname(2),
4440 isprint(3),
4441 kill(1),
4442 localtime(3),
4443 lstat(2),
4444 modload(8),
4445 mount(8),
4446 netstat(1),
4447 ofiles(8L),
4448 perl(1),
4449 ps(1),
4450 readlink(2),
4451 setlocale(3),
4452 stat(2),
4453 strftime(3),
4454 time(2),
4455 uname(1).