-
Notifications
You must be signed in to change notification settings - Fork 106
/
Lsof.8
4661 lines (4653 loc) · 123 KB
/
Lsof.8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
.so ./version
.TH LSOF 8 Revision-\*(VN
.\" Register )P is used neither by this file nor any groff macro. However,
.\" some versions of nroff require it.
.if !\n(.g \{\
. if !\n()P .nr )P 1v
.\}
.SH NAME
lsof \- list open files
.SH SYNOPSIS
.B lsof
[
.B \-?abChHlnNOPQRtUvVX
] [
.BI \-A " A"
] [
.BI \-c " c"
] [
.BI +c " c"
] [
.BI +|\-d " d"
] [
.BI +|\-D " D"
] [
.BI +|\-e " s"
] [
.B +|\-E
] [
.B +|\-f [cfgGn]
] [
.BI \-F " [f]"
] [
.BI \-g " [s]"
] [
.BI \-i " [i]"
] [
.BI \-k " k"
] [
.BI \-K " k"
] [
.BI +|\-L " [l]"
] [
.BI +|\-m " m"
] [
.B +|\-M
] [
.BI \-o " [o]"
] [
.BI \-p " s"
] [
.BI +|\-r " [t[m<fmt>]]"
] [
.BI \-s " [p:s]"
] [
.BI \-S " [t]"
] [
.BI \-T " [t]"
] [
.BI \-u " s"
] [
.B +|\-w
] [
.BI \-x " [fl]"
] [
.BI \-z " [z]"
] [
.BI \-Z " [Z]"
] [
.B \-\-
] [\fInames\fP]
.SH DESCRIPTION
.I Lsof
revision \*(VN lists on its standard output file information about files
opened by processes for the following UNIX dialects:
.PP
.nf
.so ./00DIALECTS
.fi
.PP
(See the
.B DISTRIBUTION
section of this manual page for information on how to obtain the
latest
.I lsof
revision.)
.PP
An open file may be a regular file, a directory, a block special file,
a character special file, an executing text reference, a library,
a stream or a network file (Internet socket, NFS file or UNIX domain socket.)
A specific file or all the files in a file system may be selected by path.
.PP
Instead of a formatted display,
.I lsof
will produce output that can be parsed by other programs.
See the
.BR \-F ,
option description, and the
.B "OUTPUT FOR OTHER PROGRAMS"
section for more information.
.PP
In addition to producing a single output list,
.I lsof
will run in repeat mode.
In repeat mode it will produce output, delay, then repeat the output
operation until stopped with an interrupt or quit signal.
See the
.BI +|\-r " [t[m<fmt>]]"
option description for more information.
.SH OPTIONS
In the absence of any options,
.I lsof
lists all open files belonging to all active processes.
.PP
If any list request option is specified, other list requests must be
specifically requested \- e.g., if
.B \-U
is specified for the listing of UNIX socket files, NFS files won't be
listed unless
.B \-N
is also specified;
or if a user list is specified with the
.B \-u
option, UNIX domain socket files, belonging to users not in the list,
won't be listed unless the
.B \-U
option is also specified.
.PP
Normally, list options that are specifically stated are ORed \- i.e.,
specifying the
.B \-i
option without an address and the \fB\-u\fPfoo option produces a
listing of all network files OR files belonging to processes owned
by user ``foo''.
The exceptions are:
.TP \w'1)\ 'u
1)
the `^' (negated) login name or user ID (UID), specified with the
.B \-u
option;
.TP \w'1)\ 'u
2)
the `^' (negated) process ID (PID), specified with the
.B \-p
option;
.TP \w'1)\ 'u
3)
the `^' (negated) process group ID (PGID), specified with the
.B \-g
option;
.TP \w'1)\ 'u
4)
the `^' (negated) command, specified with the
.B \-c
option;
.TP \w'1)\ 'u
5)
the (`^') negated TCP or UDP protocol state names, specified with the
.BI \-s " [p:s]"
option.
.PP
Since they represent exclusions, they are applied without ORing or ANDing
and take effect before any other selection criteria are applied.
.PP
The
.B \-a
option may be used to AND the selections.
For example, specifying
.BR \-a ,
.BR \-U ,
and \fB\-u\fPfoo produces a listing of only UNIX socket files that
belong to processes owned by user ``foo''.
.PP
Caution: the
.B \-a
option causes all list selection options to be ANDed; it can't
be used to cause ANDing of selected pairs of selection options
by placing it between them, even though its placement there is
acceptable.
Wherever
.B \-a
is placed, it causes the ANDing of all selection options.
.PP
Items of the same selection set \- command names, file descriptors,
network addresses, process identifiers, user identifiers, zone names,
security contexts \- are joined in a single ORed set and applied
before the result participates in ANDing.
Thus, for example, specifying \fB\-i\[email protected], \fB\-i\[email protected],
.BR \-a ,
and \fB\-u\fPfff,ggg will select the listing of files that belong to
either login ``fff'' OR ``ggg'' AND have network connections to either
host aaa.bbb OR ccc.ddd.
.PP
Options may be grouped together following a single prefix -- e.g.,
the option set ``\fB\-a \-b \-C\fP'' may be stated as
.BR \-abC .
However, since values are optional following
.BR +|\-f ,
.BR \-F ,
.BR \-g ,
.BR \-i ,
.BR +|\-L ,
.BR \-o ,
.BR +|\-r ,
.BR \-s ,
.BR \-S ,
.BR \-T ,
.B \-x
and
.BR \-z .
when you have no values for them be careful that the
following character isn't ambiguous.
For example,
.B \-Fn
might represent the
.B \-F
and
.B \-n
options, or it might represent the
.B n
field identifier character following the
.B \-F
option.
When ambiguity is possible, start a new option with a `\-'
character \- e.g., ``\fB\-F \-n\fP''.
If the next option is a file name, follow the possibly ambiguous
option with ``\-\-'' \- e.g., ``\fB\-F \-\- \fIname\fR''.
.PP
Either the `+' or the `\-' prefix may be applied to a group of options.
Options that don't take on separate meanings for each
prefix \- e.g., \fB\-i\fP \- may be grouped under either prefix.
Thus, for example, ``+M \-i'' may be stated as ``+Mi'' and the group
means the same as the separate options.
Be careful of prefix grouping when one or more options in the group
does take on separate meanings under different prefixes \-
e.g., \fB+|\-M\fP; ``\-iM'' is not the same request as ``\-i +M''.
When in doubt, use separate options with appropriate prefixes.
.TP \w'names'u+4
.B \-? \-h
These two equivalent options select a usage (help) output list.
.I Lsof
displays a shortened form of this output when it detects an error
in the options supplied to it, after it has displayed messages
explaining each error.
(Escape the `?' character as your shell requires.)
.TP \w'names'u+4
.B \-a
causes list selection options to be ANDed, as described above.
.TP \w'names'u+4
.BI \-A " A"
is available on systems configured for AFS whose AFS
kernel code is implemented via dynamic modules.
It allows the
.I lsof
user to specify
.I A
as an alternate name list file where the kernel addresses of the dynamic
modules might be found.
See the
.I lsof
FAQ (The \fBFAQ\fP section gives its location.)
for more information about dynamic modules, their
symbols, and how they affect
.IR lsof .
.TP \w'names'u+4
.B \-b
causes
.I lsof
to avoid kernel functions that might block \-
.IR lstat (2),
.IR readlink (2),
and
.IR stat (2).
.IP
See the
.B "BLOCKS AND TIMEOUTS"
and
.B "AVOIDING KERNEL BLOCKS"
sections for information on using this option.
.TP \w'names'u+4
.BI \-c " c"
selects the listing of files for processes executing the
command that begins with the characters of
.IR c .
Multiple commands may be specified, using multiple
.B \-c
options.
They are joined in a single ORed set before participating in
AND option selection.
.IP
If
.I c
begins with a `^', then the following characters specify a command
name whose processes are to be ignored (excluded.)
.IP
If
.I c
begins and ends with a slash ('/'), the characters between the slashes
are interpreted as a regular expression.
Shell meta\-characters in the regular expression must be quoted to prevent
their interpretation by the shell.
The closing slash may be followed by these modifiers:
.IP
.nf
b the regular expression is a basic one.
.br
i ignore the case of letters.
.br
x the regular expression is an extended one
.br
(default).
.fi
.IP
See the
.I lsof
FAQ (The \fBFAQ\fP section gives its location.)
for more information on basic and extended regular
expressions.
.IP
The simple command specification is tested first.
If that test fails, the command regular expression is applied.
If the simple command test succeeds, the command regular expression
test isn't made.
This may result in ``no command found for regex:'' messages
when lsof's
.B \-V
option is specified.
.TP \w'names'u+4
.BI +c " w"
defines the maximum number of initial characters of the name,
supplied by the UNIX dialect, of the UNIX command associated with a process
to be printed in the COMMAND column.
(The
.I lsof
default is nine.)
.IP
Note that many UNIX dialects do not supply all command name characters
to
.I lsof
in the files and structures from which
.I lsof
obtains command name.
Often dialects limit the number of characters supplied in those sources.
For example, Linux 2.4.27 and Solaris 9 both limit command name length to
16 characters.
.IP
If
.I w
is zero ('0'), all command characters supplied to
.I lsof
by the UNIX dialect will be printed.
.IP
If
.I w
is less than the length of the column title, ``COMMAND'', it will
be raised to that length.
.TP \w'names'u+4
.B \-C
disables the reporting of any path name
components from the kernel's name cache.
See the
.B "KERNEL NAME CACHE"
section for more information.
.TP \w'names'u+4
.BI +d " s"
causes
.I lsof
to search for all open instances of directory
.I s
and the files and directories it contains at its top level.
.B +d
does NOT descend the directory tree, rooted at
.IR s .
The
.BI +D " D"
option may be used to request a full\-descent directory tree search,
rooted at directory
.IR D .
.IP
Processing of the
.B +d
option does not follow symbolic links within
.I s
unless the
.B \-x
or
.B \-x " l"
option is also specified.
Nor does it
search for open files on file system mount points on subdirectories of
.I s
unless the
.B \-x
or
.B \-x " f"
option is also specified.
.IP
Note: the authority of the user of this option limits it to searching for
files that the user has permission to examine with the system
.IR stat (2)
function.
.TP \w'names'u+4
.BI \-d " s"
specifies a list of file descriptors (FDs) to exclude from
or include in the output listing.
The file descriptors are specified in the comma\-separated set
.I s
\&\- e.g., ``cwd,1,3'', ``^6,^2''.
(There should be no spaces in the set.)
.IP
The list is an exclusion list if all entries of the set begin with `^'.
It is an inclusion list if no entry begins with `^'.
Mixed lists are not permitted.
.IP
A file descriptor number range may be in the set as long as
neither member is empty, both members are numbers, and the ending
member is larger than the starting one \- e.g., ``0\-7'' or ``3\-10''.
Ranges may be specified for exclusion if they have the `^' prefix \-
e.g., ``^0\-7'' excludes all file descriptors 0 through 7.
.IP
Multiple file descriptor numbers are joined in a single ORed set before
participating in AND option selection.
.IP
When there are exclusion and inclusion members in the set,
.I lsof
reports them as errors and exits with a non\-zero return code.
.IP
See the description of File Descriptor (FD) output values in the
.B OUTPUT
section for more information on file descriptor names.
.IP
\fBfd\fP is a pseudo file descriptor name for specifying
the whole range of possible file descriptor numbers.
\fBfd\fP does not appear in FD column of output.
.TP \w'names'u+4
.BI +D " D"
causes
.I lsof
to search for all open instances of directory
.I D
and all the files and directories it contains to its complete depth.
.IP
Processing of the
.B +D
option does not follow symbolic links within
.I D
unless the
.B \-x
or
.B \-x " l"
option is also specified.
Nor does it
search for open files on file system mount points on subdirectories of
.I D
unless the
.B \-x
or
.B \-x " f"
option is also specified.
.IP
Note: the authority of the user of this option limits it to searching for
files that the user has permission to examine with the system
.IR stat (2)
function.
.IP
Further note:
.I lsof
may process this option slowly and require a large amount of dynamic memory
to do it.
This is because it must descend the entire directory tree, rooted at
.IR D ,
calling
.IR stat (2)
for each file and directory, building a list of all the files it finds, and
searching that list for a match with every open file.
When directory
.I D
is large, these steps can take a long time, so use this option prudently.
.TP \w'names'u+4
.BI \-D " D"
directs
.I lsof's
use of the device cache file.
The use of this option is sometimes restricted.
See the
.B "DEVICE CACHE FILE"
section and the sections that follow it for more information on this
option.
.IP
.B \-D
must be followed by a function letter; the function letter may optionally
be followed by a path name.
.I Lsof
recognizes these function letters:
.IP
.nf
\fB?\fP \- report device cache file paths
\fBb\fP \- build the device cache file
\fBi\fP \- ignore the device cache file
\fBr\fP \- read the device cache file
\fBu\fP \- read and update the device cache file
.fi
.IP
The
.BR b ,
.BR r ,
and
.B u
functions, accompanied by a path name, are sometimes restricted.
When these functions are restricted, they will not appear in
the description of the
.B \-D
option that accompanies
.B \-h
or
.B \-?
option output.
See the
.B "DEVICE CACHE FILE"
section and the sections that follow it for more information on these
functions and when they're restricted.
.IP
The
.B ?
function reports the read\-only and write paths that lsof can
use for the device cache file,
the names of any environment variables whose values
.I lsof
will examine when forming the device cache file path,
and the format for the personal device cache file path.
(Escape the `?' character as your shell requires.)
.IP
When available, the
.BR b ,
.BR r ,
and
.B u
functions may be followed by the device cache file's path.
The standard default is
.I .lsof_hostname
in the home directory of the real user ID that executes
.IR lsof ,
but this could have been changed when
.I lsof
was configured and compiled.
(The output of the
.B \-h
and
.B \-?
options show the current default prefix \- e.g., ``.lsof''.)
The suffix,
.IR hostname ,
is the first component of the host's name returned by
.IR gethostname (2).
.IP
When available, the
.B b
function directs
.I lsof
to build a new device cache file at the default or specified path.
.IP
The
.B i
function directs
.I lsof
to ignore the default device cache file and obtain its information
about devices via direct calls to the kernel.
.IP
The
.B r
function directs
.I lsof
to read the device cache at the default or specified path, but
prevents it from creating a new device cache file when none
exists or the existing one is improperly structured.
The
.B r
function, when specified without a path name, prevents
.I lsof
from updating an incorrect or outdated device cache file,
or creating a new one in its place.
The
.B r
function is always available when it is specified without a
path name argument; it may be restricted by the permissions of the
.I lsof
process.
.IP
When available, the
.B u
function directs
.I lsof
to read the device cache file at the default or specified path,
if possible, and to rebuild it, if necessary.
This is the default device cache file function when no
.B \-D
option has been specified.
.TP \w'names'u+4
.BI +|\-e " s"
exempts the file system whose path name is
.I s
from being subjected to kernel function calls that might block.
The
.B +e
option exempts
.IR stat (2),
.IR lstat (2)
and most
.IR readlink (2)
kernel function calls.
The
.B \-e
option exempts only
.IR stat(2)
and
.IR lstat (2)
kernel function calls.
Multiple file systems may be specified with separate
.B +|\-e
specifications and each may have
.IR readlink (2)
calls exempted or not.
.IP
This option is currently implemented only for Linux.
.IP
.B CAUTION:
this option can easily be mis\-applied to other than
the file system of interest, because it uses path name rather
than the more reliable device and inode numbers.
(Device and inode numbers are acquired via the potentially blocking
.IR stat (2)
kernel call and are thus not available, but see the
.BI +|\-m " m"
option as a possible alternative way to supply device numbers.)
\fBUse this option with great care and fully specify the path name of the
file system to be exempted.\fP
.IP
When open files on exempted file systems are reported, it may not be
possible to obtain all their information.
Therefore, some information columns will be blank, the characters ``UNKN''
preface the values in the TYPE column, and the applicable exemption option
is added in parentheses to the end of the NAME column.
(Some device number information might be made available via the
.BI +|\-m " m"
option.)
.TP \w'names'u+4
.B +|\-E
.B +E
specifies that Linux pipe, Linux UNIX socket, Linux INET(6) socket closed in a local host, Linux pseudoterminal files,
POSIX Message Queueue implementation in Linux, and Linux eventfd
should be displayed with endpoint information and the files of the endpoints should also be displayed.
.IP
Note 1: UNIX socket file endpoint information is only available when the
features enabled line of
.B \-v
output contains uxsockept, and psudoterminal endpoint information is only
available when the features enabled line contains ptyept.
.IP
Note 2: POSIX Message Queue file endpoint information is only available when mqueue
file system is mounted.
.IP
Pipe endpoint information is displayed in the NAME column in the
form ``\fIPID,cmd,FDmode\fP'', where
.I PID
is the endpoint process ID;
.I cmd
is the endpoint process command;
.I FD
is the endpoint file's descriptor; and
.I mode
is the endpoint file's access mode.
.IP
Pseudoterminal
endpoint information is displayed in the NAME column as
``\->/dev/pts\fImin\fP\ \fIPID,cmd,FDmode\fP'' or ``\fIPID,cmd,FDmode\fP''.
The first form is for a master device; the second, for a slave device.
.I min
is a slave device's minor device number; and
.I "PID, cmd, FD"
and
.I mode
are the same as with pipe endpoint information.
Note: psudoterminal endpoint information is only available when the features
enabled line of
.B \-v
output contains ptyept. In addition, this feature works on Linux kernels above 4.13.0.
.IP
UNIX socket file endpoint information is displayed in the NAME column
in the form
.br
``type=\fITYPE\fP\ \->INO=\fIINODE\fP\ \fIPID,cmd,FDmode\fP'', where
.I TYPE
is the socket type;
.I INODE
is the i-node number of the connected socket;
and
.I "PID, cmd, FD"
and
.I mode
are the same as with pipe endpoint information.
Note: UNIX socket file endpoint information is available only when the
features enabled line of
.B \-v
output contains uxsockept.
.IP
INET socket file endpoint information is inserted to the value at the
NAME column in the form
.br
`` \-> \fIPID,cmd,FDmode\fP'', where
.I "PID, cmd, FD"
and
.I mode
are the same as with pipe endpoint information. The endpoint
information is available only if the socket is used for local
IPC; both endpoints bind to the same local IPv4 or IPv6 address.
.IP
POSIX Message Queue file endpoint information is displayed in the NAME
column in the same form as that of pipe.
.IP
eventfd endpoint information is displayed in the NAME column in
the same form as that of pipe. This feature works on Linux kernels
above 5.2.0.
.IP
Multiple occurrences of this information can appear in a file's
NAME column.
.IP
.B \-E
specifies that endpoint supported files should be displayed
with endpoint information, but not the files of the endpoints.
.TP \w'names'u+4
.B +|\-f [cfgGn]
.B f
by itself clarifies how path name arguments are to be interpreted.
When followed by
.BR c ,
.BR f ,
.BR g ,
.BR G ,
or
.B n
in any combination it specifies
that the listing of kernel file structure information is to be enabled
(`+') or inhibited (`\-').
.IP
Normally a path name argument is taken to be a file system name if
it matches a mounted\-on directory name reported by
.IR mount (8),
or if it represents a block device, named in the
.I mount
output and associated with a mounted directory name.
When
.B +f
is specified, all path name arguments will be taken to be file
system names, and
.I lsof
will complain if any are not.
This can be useful, for example, when the file system name
(mounted\-on device) isn't a block device.
This happens for some CD-ROM file systems.
.IP
When
.B \-f
is specified by itself, all path name arguments will be taken to be
simple files.
Thus, for example, the ``\fB\-f\fP\ \-\- /'' arguments direct lsof to search
for open files with a `/' path name, not all open files in the `/'
(root) file system.
.IP
Be careful to make sure
.B +f
and
.B \-f
are properly terminated and aren't followed by a character (e.g., of
the file or file system name) that might be taken as a parameter.
For example, use ``\-\-'' after
.B +f
and
.B \-f
as in these examples.
.IP
.nf
$ lsof +f \-\- /file/system/name
$ lsof \-f \-\- /file/name
.fi
.IP
The listing of information from kernel file structures, requested with the
.B +f [cfgGn]
option form, is normally
inhibited, and is not available in whole or part for some dialects \- e.g.,
/proc\-based Linux kernels below 2.6.22.
When the prefix to
.B f
is a plus sign (`+'), these characters request file structure information:
.IP
.nf
\fBc\fR file structure use count (not Linux)
\fBf\fR file structure address (not Linux)
\fBg\fR file flag abbreviations (Linux 2.6.22 and up)
Abbrev. Flag in C code (see open(2))
\fBW\fR O_WRONLY
\fBRW\fR O_RDWR
\fBCR\fR O_CREAT
\fBEXCL\fR O_EXCL
\fBNTTY\fR O_NOCTTY
\fBTR\fR O_TRUNC
\fBAP\fR O_APPEND
\fBND\fR O_NDELAY
\fBSYN\fR O_SYNC
\fBASYN\fR O_ASYNC
\fBDIR\fR O_DIRECT
\fBDTY\fR O_DIRECTORY
\fBNFLK\fR O_NOFOLLOW
\fBNATM\fR O_NOATIME
\fBDSYN\fR O_DSYNC
\fBRSYN\fR O_RSYNC
\fBLG\fR O_LARGEFILE
\fBCX\fR O_CLOEXEC
\fBTMPF\fR O_TMPFILE
\fBG\fR file flags in hexadecimal (Linux 2.6.22 and up)
\fBn\fR file structure node address (not Linux)
.fi
.IP
When the prefix is minus (`\-') the same characters disable the
listing of the indicated values.
.IP
File structure addresses, use counts, flags, and node addresses may be
used to detect more readily identical files inherited by child
processes and identical files in use by different processes.
.I Lsof
column output can be sorted by output columns holding the values
and listed to identify identical file use, or
.I lsof
field output can be parsed by an AWK or Perl post\-filter script,
or by a C program.
.TP \w'names'u+4
.BI \-F " f"
specifies a character list,
.IR f ,
that selects the fields to be output for processing by another program,
and the character that terminates each output field.
Each field to be output is specified with a single character in
.IR f .
The field terminator defaults to NL, but may be changed to NUL (000).
See the
.B "OUTPUT FOR OTHER PROGRAMS"
section for a description of the field identification characters and
the field output process.
.IP
When the field selection character list is empty, all standard fields are
selected (except the raw device field, security context and zone field for
compatibility reasons)
and the NL field terminator is used.
.IP
When the field selection character list contains only a zero (`0'),
all fields are selected (except the raw device field for compatibility
reasons) and the NUL terminator character is used.
.IP
Other combinations of fields and their associated field terminator
character must be set with explicit entries in
.IR f ,
as described in the
.B "OUTPUT FOR OTHER PROGRAMS"
section.
.IP
When a field selection character identifies an item
.I lsof
does not normally list \- e.g., PPID, selected with
.BR \-R " \-"
specification of the field character \- e.g., ``\fB\-FR\fP'' \-
also selects the listing of the item.
.IP
When the field selection character list contains the single
character `?',
.I lsof
will display a help list of the field identification characters.
(Escape the `?' character as your shell requires.)
.TP \w'names'u+4
.BI \-g " [s]"
excludes or selects the listing of files for the processes
whose optional process group IDentification (PGID) numbers are in the
comma\-separated set
.I s
\&\- e.g., ``123'' or ``123,^456''.
(There should be no spaces in the set.)
.IP
PGID numbers that begin with `^' (negation) represent exclusions.
.IP
Multiple PGID numbers are joined in a single ORed set before participating
in AND option selection.
However, PGID exclusions are applied without ORing or ANDing
and take effect before other selection criteria are applied.
.IP
The
.B \-g
option also enables the output display of PGID numbers.
When specified without a PGID set that's all it does.
.TP \w'names'u+4
.B \-H
directs lsof to print human readable sizes, e.g. 123.4K 456.7M.
.TP \w'names'u+4
.BI \-i " [i]"
selects the listing of files any of whose Internet address
matches the address specified in \fIi\fP.
If no address is specified, this option selects the listing of all
Internet and x.25 (HP\-UX) network files.
.IP
If
.BI \-i 4
or
.BI \-i 6
is specified with no following address, only files of the indicated
IP version, IPv4 or IPv6, are displayed.
(An IPv6 specification may be used only if the dialects supports IPv6,
as indicated by ``[46]'' and ``IPv[46]'' in
.I lsof's
.B \-h
or
.B \-?
output.)
Sequentially specifying
.BR \-i 4,
followed by
.BR \-i 6
is the same as specifying
.BR \-i ,
and vice-versa.
Specifying
.BR \-i 4,
or
.BR \-i 6
after
.B \-i
is the same as specifying
.BR \-i 4
or
.BR \-i 6
by itself.
.IP
Multiple addresses (up to a limit of 100) may be specified with multiple
.B \-i
options.
(A port number or service name range is counted as one address.)
They are joined in a single ORed set before participating in
AND option selection.
.IP
An Internet address is specified in the form (Items in square
brackets are optional.):
.IP
.ie !\n(.g \{
[\fI46\fP][\fIprotocol\fP][@\fIhostname\fP\||\|\fIhostaddr\fP][:\fIservice\fP\||\|\fIport\fP]
\}
.el \{
.RI [ 46 ][ protocol ][@ hostname \||\| hostaddr ][: service \||\| port ]
\}
.IP
where:
.nf
.br
\fI46\fP specifies the IP version, IPv4 or IPv6
.br
that applies to the following address.
.br
'6' may be be specified only if the UNIX
.br
dialect supports IPv6. If neither '4' nor
.br
'6' is specified, the following address
.br
applies to all IP versions.
.br
\fIprotocol\fP is a protocol name \- \fBTCP\fP, \fBUDP\fP or \fBUDPLITE\fP.
.br
.br
\fIhostname\fP is an Internet host name. Unless a
.br
specific IP version is specified, open
.br
network files associated with host names
.br
of all versions will be selected.
.br
\fIhostaddr\fP is a numeric Internet IPv4 address in
.br
dot form; or an IPv6 numeric address in
.br
colon form, enclosed in brackets, if the
.br
UNIX dialect supports IPv6. When an IP
.br
version is selected, only its numeric
.br
addresses may be specified.
.br
\fIservice\fP is an \fI/etc/services\fP name \- e.g., \fBsmtp\fP \-
or a list of them.
.br
\fIport\fP is a port number, or a list of them.
.fi