1LSOF(8) System Manager's Manual LSOF(8)
2
3
4
6 lsof - list open files
7
9 lsof [ -?abChlnNOPRtUvVX ] [ -A A ] [ -c c ] [ +c c ] [ +|-d d ] [ +|-D
10 D ] [ +|-e s ] [ +|-f [cfgGn] ] [ -F [f] ] [ -g [s] ] [ -i [i] ] [ -k k
11 ] [ -K k ] [ +|-L [l] ] [ +|-m m ] [ +|-M ] [ -o [o] ] [ -p s ] [ +|-r
12 [t[m<fmt>]] ] [ -s [p:s] ] [ -S [t] ] [ -T [t] ] [ -u s ] [ +|-w ] [ -x
13 [fl] ] [ -z [z] ] [ -Z [Z] ] [ -- ] [names]
14
16 Lsof revision 4.87 lists on its standard output file information about
17 files opened by processes for the following UNIX dialects:
18
19 Apple Darwin 9 and Mac OS X 10.[567]
20 FreeBSD 4.9 and 6.4 for x86-based systems
21 FreeBSD 8.2, 9.0 and 10.0 for AMD64-based systems
22 Linux 2.1.72 and above for x86-based systems
23 Solaris 9, 10 and 11
24
25 (See the DISTRIBUTION section of this manual page for information on
26 how to obtain the latest lsof revision.)
27
28 An open file may be a regular file, a directory, a block special file,
29 a character special file, an executing text reference, a library, a
30 stream or a network file (Internet socket, NFS file or UNIX domain
31 socket.) A specific file or all the files in a file system may be
32 selected by path.
33
34 Instead of a formatted display, lsof will produce output that can be
35 parsed by other programs. See the -F, option description, and the OUT‐
36 PUT FOR OTHER PROGRAMS section for more information.
37
38 In addition to producing a single output list, lsof will run in repeat
39 mode. In repeat mode it will produce output, delay, then repeat the
40 output operation until stopped with an interrupt or quit signal. See
41 the +|-r [t[m<fmt>]] option description for more information.
42
44 In the absence of any options, lsof lists all open files belonging to
45 all active processes.
46
47 If any list request option is specified, other list requests must be
48 specifically requested - e.g., if -U is specified for the listing of
49 UNIX socket files, NFS files won't be listed unless -N is also speci‐
50 fied; or if a user list is specified with the -u option, UNIX domain
51 socket files, belonging to users not in the list, won't be listed
52 unless the -U option is also specified.
53
54 Normally list options that are specifically stated are ORed - i.e.,
55 specifying the -i option without an address and the -ufoo option pro‐
56 duces a listing of all network files OR files belonging to processes
57 owned by user ``foo''. The exceptions are:
58
59 1) the `^' (negated) login name or user ID (UID), specified with the -u
60 option;
61
62 2) the `^' (negated) process ID (PID), specified with the -p option;
63
64 3) the `^' (negated) process group ID (PGID), specified with the -g
65 option;
66
67 4) the `^' (negated) command, specified with the -c option;
68
69 5) the (`^') negated TCP or UDP protocol state names, specified with
70 the -s [p:s] option.
71
72 Since they represent exclusions, they are applied without ORing or AND‐
73 ing and take effect before any other selection criteria are applied.
74
75 The -a option may be used to AND the selections. For example, specify‐
76 ing -a, -U, and -ufoo produces a listing of only UNIX socket files that
77 belong to processes owned by user ``foo''.
78
79 Caution: the -a option causes all list selection options to be ANDed;
80 it can't be used to cause ANDing of selected pairs of selection options
81 by placing it between them, even though its placement there is accept‐
82 able. Wherever -a is placed, it causes the ANDing of all selection
83 options.
84
85 Items of the same selection set - command names, file descriptors, net‐
86 work addresses, process identifiers, user identifiers, zone names,
87 security contexts - are joined in a single ORed set and applied before
88 the result participates in ANDing. Thus, for example, specifying
89 -i@aaa.bbb, -i@ccc.ddd, -a, and -ufff,ggg will select the listing of
90 files that belong to either login ``fff'' OR ``ggg'' AND have network
91 connections to either host aaa.bbb OR ccc.ddd.
92
93 Options may be grouped together following a single prefix -- e.g., the
94 option set ``-a -b -C'' may be stated as -abC. However, since values
95 are optional following +|-f, -F, -g, -i, +|-L, -o, +|-r, -s, -S, -T, -x
96 and -z. when you have no values for them be careful that the following
97 character isn't ambiguous. For example, -Fn might represent the -F and
98 -n options, or it might represent the n field identifier character fol‐
99 lowing the -F option. When ambiguity is possible, start a new option
100 with a `-' character - e.g., ``-F -n''. If the next option is a file
101 name, follow the possibly ambiguous option with ``--'' - e.g., ``-F --
102 name''.
103
104 Either the `+' or the `-' prefix may be applied to a group of options.
105 Options that don't take on separate meanings for each prefix - e.g., -i
106 - may be grouped under either prefix. Thus, for example, ``+M -i'' may
107 be stated as ``+Mi'' and the group means the same as the separate
108 options. Be careful of prefix grouping when one or more options in the
109 group does take on separate meanings under different prefixes - e.g.,
110 +|-M; ``-iM'' is not the same request as ``-i +M''. When in doubt, use
111 separate options with appropriate prefixes.
112
113 -? -h These two equivalent options select a usage (help) output
114 list. Lsof displays a shortened form of this output when it
115 detects an error in the options supplied to it, after it has
116 displayed messages explaining each error. (Escape the `?'
117 character as your shell requires.)
118
119 -a causes list selection options to be ANDed, as described above.
120
121 -A A is available on systems configured for AFS whose AFS kernel
122 code is implemented via dynamic modules. It allows the lsof
123 user to specify A as an alternate name list file where the
124 kernel addresses of the dynamic modules might be found. See
125 the lsof FAQ (The FAQ section gives its location.) for more
126 information about dynamic modules, their symbols, and how they
127 affect lsof.
128
129 -b causes lsof to avoid kernel functions that might block -
130 lstat(2), readlink(2), and stat(2).
131
132 See the BLOCKS AND TIMEOUTS and AVOIDING KERNEL BLOCKS sec‐
133 tions for information on using this option.
134
135 -c c selects the listing of files for processes executing the com‐
136 mand that begins with the characters of c. Multiple commands
137 may be specified, using multiple -c options. They are joined
138 in a single ORed set before participating in AND option selec‐
139 tion.
140
141 If c begins with a `^', then the following characters specify
142 a command name whose processes are to be ignored (excluded.)
143
144 If c begins and ends with a slash ('/'), the characters
145 between the slashes are interpreted as a regular expression.
146 Shell meta-characters in the regular expression must be quoted
147 to prevent their interpretation by the shell. The closing
148 slash may be followed by these modifiers:
149
150 b the regular expression is a basic one.
151 i ignore the case of letters.
152 x the regular expression is an extended one
153 (default).
154
155 See the lsof FAQ (The FAQ section gives its location.) for
156 more information on basic and extended regular expressions.
157
158 The simple command specification is tested first. If that
159 test fails, the command regular expression is applied. If the
160 simple command test succeeds, the command regular expression
161 test isn't made. This may result in ``no command found for
162 regex:'' messages when lsof's -V option is specified.
163
164 +c w defines the maximum number of initial characters of the name,
165 supplied by the UNIX dialect, of the UNIX command associated
166 with a process to be printed in the COMMAND column. (The lsof
167 default is nine.)
168
169 Note that many UNIX dialects do not supply all command name
170 characters to lsof in the files and structures from which lsof
171 obtains command name. Often dialects limit the number of
172 characters supplied in those sources. For example, Linux
173 2.4.27 and Solaris 9 both limit command name length to 16
174 characters.
175
176 If w is zero ('0'), all command characters supplied to lsof by
177 the UNIX dialect will be printed.
178
179 If w is less than the length of the column title, ``COMMAND'',
180 it will be raised to that length.
181
182 -C disables the reporting of any path name components from the
183 kernel's name cache. See the KERNEL NAME CACHE section for
184 more information.
185
186 +d s causes lsof to search for all open instances of directory s
187 and the files and directories it contains at its top level.
188 +d does NOT descend the directory tree, rooted at s. The +D D
189 option may be used to request a full-descent directory tree
190 search, rooted at directory D.
191
192 Processing of the +d option does not follow symbolic links
193 within s unless the -x or -x l option is also specified. Nor
194 does it search for open files on file system mount points on
195 subdirectories of s unless the -x or -x f option is also
196 specified.
197
198 Note: the authority of the user of this option limits it to
199 searching for files that the user has permission to examine
200 with the system stat(2) function.
201
202 -d s specifies a list of file descriptors (FDs) to exclude from or
203 include in the output listing. The file descriptors are spec‐
204 ified in the comma-separated set s - e.g., ``cwd,1,3'',
205 ``^6,^2''. (There should be no spaces in the set.)
206
207 The list is an exclusion list if all entries of the set begin
208 with `^'. It is an inclusion list if no entry begins with
209 `^'. Mixed lists are not permitted.
210
211 A file descriptor number range may be in the set as long as
212 neither member is empty, both members are numbers, and the
213 ending member is larger than the starting one - e.g., ``0-7''
214 or ``3-10''. Ranges may be specified for exclusion if they
215 have the `^' prefix - e.g., ``^0-7'' excludes all file
216 descriptors 0 through 7.
217
218 Multiple file descriptor numbers are joined in a single ORed
219 set before participating in AND option selection.
220
221 When there are exclusion and inclusion members in the set,
222 lsof reports them as errors and exits with a non-zero return
223 code.
224
225 See the description of File Descriptor (FD) output values in
226 the OUTPUT section for more information on file descriptor
227 names.
228
229 +D D causes lsof to search for all open instances of directory D
230 and all the files and directories it contains to its complete
231 depth.
232
233 Processing of the +D option does not follow symbolic links
234 within D unless the -x or -x l option is also specified. Nor
235 does it search for open files on file system mount points on
236 subdirectories of D unless the -x or -x f option is also
237 specified.
238
239 Note: the authority of the user of this option limits it to
240 searching for files that the user has permission to examine
241 with the system stat(2) function.
242
243 Further note: lsof may process this option slowly and require
244 a large amount of dynamic memory to do it. This is because it
245 must descend the entire directory tree, rooted at D, calling
246 stat(2) for each file and directory, building a list of all
247 the files it finds, and searching that list for a match with
248 every open file. When directory D is large, these steps can
249 take a long time, so use this option prudently.
250
251 -D D directs lsof's use of the device cache file. The use of this
252 option is sometimes restricted. See the DEVICE CACHE FILE
253 section and the sections that follow it for more information
254 on this option.
255
256 -D must be followed by a function letter; the function letter
257 may optionally be followed by a path name. Lsof recognizes
258 these function letters:
259
260 ? - report device cache file paths
261 b - build the device cache file
262 i - ignore the device cache file
263 r - read the device cache file
264 u - read and update the device cache file
265
266 The b, r, and u functions, accompanied by a path name, are
267 sometimes restricted. When these functions are restricted,
268 they will not appear in the description of the -D option that
269 accompanies -h or -? option output. See the DEVICE CACHE
270 FILE section and the sections that follow it for more informa‐
271 tion on these functions and when they're restricted.
272
273 The ? function reports the read-only and write paths that
274 lsof can use for the device cache file, the names of any envi‐
275 ronment variables whose values lsof will examine when forming
276 the device cache file path, and the format for the personal
277 device cache file path. (Escape the `?' character as your
278 shell requires.)
279
280 When available, the b, r, and u functions may be followed by
281 the device cache file's path. The standard default is
282 .lsof_hostname in the home directory of the real user ID that
283 executes lsof, but this could have been changed when lsof was
284 configured and compiled. (The output of the -h and -?
285 options show the current default prefix - e.g., ``.lsof''.)
286 The suffix, hostname, is the first component of the host's
287 name returned by gethostname(2).
288
289 When available, the b function directs lsof to build a new
290 device cache file at the default or specified path.
291
292 The i function directs lsof to ignore the default device cache
293 file and obtain its information about devices via direct calls
294 to the kernel.
295
296 The r function directs lsof to read the device cache at the
297 default or specified path, but prevents it from creating a new
298 device cache file when none exists or the existing one is
299 improperly structured. The r function, when specified without
300 a path name, prevents lsof from updating an incorrect or out‐
301 dated device cache file, or creating a new one in its place.
302 The r function is always available when it is specified with‐
303 out a path name argument; it may be restricted by the permis‐
304 sions of the lsof process.
305
306 When available, the u function directs lsof to read the device
307 cache file at the default or specified path, if possible, and
308 to rebuild it, if necessary. This is the default device cache
309 file function when no -D option has been specified.
310
311 +|-e s exempts the file system whose path name is s from being sub‐
312 jected to kernel function calls that might block. The +e
313 option exempts stat(2), lstat(2) and most readlink(2) kernel
314 function calls. The -e option exempts only stat(2) and
315 lstat(2) kernel function calls. Multiple file systems may be
316 specified with separate +|-e specifications and each may have
317 readlink(2) calls exempted or not.
318
319 This option is currently implemented only for Linux.
320
321 CAUTION: this option can easily be mis-applied to other than
322 the file system of interest, because it uses path name rather
323 than the more reliable device and inode numbers. (Device and
324 inode numbers are acquired via the potentially blocking
325 stat(2) kernel call and are thus not available, but see the
326 +|-m m option as a possible alternative way to supply device
327 numbers.) Use this option with great care and fully specify
328 the path name of the file system to be exempted.
329
330 When open files on exempted file systems are reported, it may
331 not be possible to obtain all their information. Therefore,
332 some information columns will be blank, the characters
333 ``UNKN'' preface the values in the TYPE column, and the appli‐
334 cable exemption option is added in parentheses to the end of
335 the NAME column. (Some device number information might be
336 made available via the +|-m m option.)
337
338 +|-f [cfgGn]
339 f by itself clarifies how path name arguments are to be inter‐
340 preted. When followed by c, f, g, G, or n in any combination
341 it specifies that the listing of kernel file structure infor‐
342 mation is to be enabled (`+') or inhibited (`-').
343
344 Normally a path name argument is taken to be a file system
345 name if it matches a mounted-on directory name reported by
346 mount(8), or if it represents a block device, named in the
347 mount output and associated with a mounted directory name.
348 When +f is specified, all path name arguments will be taken to
349 be file system names, and lsof will complain if any are not.
350 This can be useful, for example, when the file system name
351 (mounted-on device) isn't a block device. This happens for
352 some CD-ROM file systems.
353
354 When -f is specified by itself, all path name arguments will
355 be taken to be simple files. Thus, for example, the ``-f --
356 /'' arguments direct lsof to search for open files with a `/'
357 path name, not all open files in the `/' (root) file system.
358
359 Be careful to make sure +f and -f are properly terminated and
360 aren't followed by a character (e.g., of the file or file sys‐
361 tem name) that might be taken as a parameter. For example,
362 use ``--'' after +f and -f as in these examples.
363
364 $ lsof +f -- /file/system/name
365 $ lsof -f -- /file/name
366
367 The listing of information from kernel file structures,
368 requested with the +f [cfgGn] option form, is normally inhib‐
369 ited, and is not available in whole or part for some dialects
370 - e.g., /proc-based Linux kernels below 2.6.22. When the pre‐
371 fix to f is a plus sign (`+'), these characters request file
372 structure information:
373
374 c file structure use count (not Linux)
375 f file structure address (not Linux)
376 g file flag abbreviations (Linux 2.6.22 and up)
377 G file flags in hexadecimal (Linux 2.6.22 and up)
378 n file structure node address (not Linux)
379
380 When the prefix is minus (`-') the same characters disable the
381 listing of the indicated values.
382
383 File structure addresses, use counts, flags, and node
384 addresses may be used to detect more readily identical files
385 inherited by child processes and identical files in use by
386 different processes. Lsof column output can be sorted by out‐
387 put columns holding the values and listed to identify identi‐
388 cal file use, or lsof field output can be parsed by an AWK or
389 Perl post-filter script, or by a C program.
390
391 -F f specifies a character list, f, that selects the fields to be
392 output for processing by another program, and the character
393 that terminates each output field. Each field to be output is
394 specified with a single character in f. The field terminator
395 defaults to NL, but may be changed to NUL (000). See the OUT‐
396 PUT FOR OTHER PROGRAMS section for a description of the field
397 identification characters and the field output process.
398
399 When the field selection character list is empty, all standard
400 fields are selected (except the raw device field, security
401 context and zone field for compatibility reasons) and the NL
402 field terminator is used.
403
404 When the field selection character list contains only a zero
405 (`0'), all fields are selected (except the raw device field
406 for compatibility reasons) and the NUL terminator character is
407 used.
408
409 Other combinations of fields and their associated field termi‐
410 nator character must be set with explicit entries in f, as
411 described in the OUTPUT FOR OTHER PROGRAMS section.
412
413 When a field selection character identifies an item lsof does
414 not normally list - e.g., PPID, selected with -R - specifica‐
415 tion of the field character - e.g., ``-FR'' - also selects the
416 listing of the item.
417
418 When the field selection character list contains the single
419 character `?', lsof will display a help list of the field
420 identification characters. (Escape the `?' character as your
421 shell requires.)
422
423 -g [s] excludes or selects the listing of files for the processes
424 whose optional process group IDentification (PGID) numbers are
425 in the comma-separated set s - e.g., ``123'' or ``123,^456''.
426 (There should be no spaces in the set.)
427
428 PGID numbers that begin with `^' (negation) represent exclu‐
429 sions.
430
431 Multiple PGID numbers are joined in a single ORed set before
432 participating in AND option selection. However, PGID exclu‐
433 sions are applied without ORing or ANDing and take effect
434 before other selection criteria are applied.
435
436 The -g option also enables the output display of PGID numbers.
437 When specified without a PGID set that's all it does.
438
439 -i [i] selects the listing of files any of whose Internet address
440 matches the address specified in i. If no address is speci‐
441 fied, this option selects the listing of all Internet and x.25
442 (HP-UX) network files.
443
444 If -i4 or -i6 is specified with no following address, only
445 files of the indicated IP version, IPv4 or IPv6, are dis‐
446 played. (An IPv6 specification may be used only if the
447 dialects supports IPv6, as indicated by ``[46]'' and
448 ``IPv[46]'' in lsof's -h or -? output.) Sequentially speci‐
449 fying -i4, followed by -i6 is the same as specifying -i, and
450 vice-versa. Specifying -i4, or -i6 after -i is the same as
451 specifying -i4 or -i6 by itself.
452
453 Multiple addresses (up to a limit of 100) may be specified
454 with multiple -i options. (A port number or service name
455 range is counted as one address.) They are joined in a single
456 ORed set before participating in AND option selection.
457
458 An Internet address is specified in the form (Items in square
459 brackets are optional.):
460
461 [46][protocol][@hostname|hostaddr][:service|port]
462
463 where:
464 46 specifies the IP version, IPv4 or IPv6
465 that applies to the following address.
466 '6' may be be specified only if the UNIX
467 dialect supports IPv6. If neither '4' nor
468 '6' is specified, the following address
469 applies to all IP versions.
470 protocol is a protocol name - TCP, UDP
471 hostname is an Internet host name. Unless a
472 specific IP version is specified, open
473 network files associated with host names
474 of all versions will be selected.
475 hostaddr is a numeric Internet IPv4 address in
476 dot form; or an IPv6 numeric address in
477 colon form, enclosed in brackets, if the
478 UNIX dialect supports IPv6. When an IP
479 version is selected, only its numeric
480 addresses may be specified.
481 service is an /etc/services name - e.g., smtp -
482 or a list of them.
483 port is a port number, or a list of them.
484
485 IPv6 options may be used only if the UNIX dialect supports
486 IPv6. To see if the dialect supports IPv6, run lsof and spec‐
487 ify the -h or -? (help) option. If the displayed description
488 of the -i option contains ``[46]'' and ``IPv[46]'', IPv6 is
489 supported.
490
491 IPv4 host names and addresses may not be specified if network
492 file selection is limited to IPv6 with -i 6. IPv6 host names
493 and addresses may not be specified if network file selection
494 is limited to IPv4 with -i 4. When an open IPv4 network
495 file's address is mapped in an IPv6 address, the open file's
496 type will be IPv6, not IPv4, and its display will be selected
497 by '6', not '4'.
498
499 At least one address component - 4, 6, protocol, hostname,
500 hostaddr, or service - must be supplied. The `@' character,
501 leading the host specification, is always required; as is the
502 `:', leading the port specification. Specify either hostname
503 or hostaddr. Specify either service name list or port number
504 list. If a service name list is specified, the protocol may
505 also need to be specified if the TCP, UDP and UDPLITE port
506 numbers for the service name are different. Use any case -
507 lower or upper - for protocol.
508
509 Service names and port numbers may be combined in a list whose
510 entries are separated by commas and whose numeric range
511 entries are separated by minus signs. There may be no embed‐
512 ded spaces, and all service names must belong to the specified
513 protocol. Since service names may contain embedded minus
514 signs, the starting entry of a range can't be a service name;
515 it can be a port number, however.
516
517 Here are some sample addresses:
518
519 -i6 - IPv6 only
520 TCP:25 - TCP and port 25
521 @1.2.3.4 - Internet IPv4 host address 1.2.3.4
522 @[3ffe:1ebc::1]:1234 - Internet IPv6 host address
523 3ffe:1ebc::1, port 1234
524 UDP:who - UDP who service port
525 TCP@lsof.itap:513 - TCP, port 513 and host name lsof.itap
526 tcp@foo:1-10,smtp,99 - TCP, ports 1 through 10,
527 service name smtp, port 99, host name foo
528 tcp@bar:1-smtp - TCP, ports 1 through smtp, host bar
529 :time - either TCP, UDP or UDPLITE time service port
530
531 -K k selects the listing of tasks (threads) of processes, on
532 dialects where task (thread) reporting is supported. (If help
533 output - i.e., the output of the -h or -? options - shows
534 this option, then task (thread) reporting is supported by the
535 dialect.)
536
537 If -K is followed by a value, k, it must be ``i''. That
538 causes lsof to ignore tasks, particularly in the default,
539 list-everything case when no other options are specified.
540
541 When -K and -a are both specified on Linux, and the tasks of a
542 main process are selected by other options, the main process
543 will also be listed as though it were a task, but without a
544 task ID. (See the description of the TID column in the OUTPUT
545 section.)
546
547 Where the FreeBSD version supports threads, all threads will
548 be listed with their IDs.
549
550 In general threads and tasks inherit the files of the caller,
551 but may close some and open others, so lsof always reports all
552 the open files of threads and tasks.
553
554 -k k specifies a kernel name list file, k, in place of /vmunix,
555 /mach, etc. -k is not available under AIX on the IBM
556 RISC/System 6000.
557
558 -l inhibits the conversion of user ID numbers to login names. It
559 is also useful when login name lookup is working improperly or
560 slowly.
561
562 +|-L [l] enables (`+') or disables (`-') the listing of file link
563 counts, where they are available - e.g., they aren't available
564 for sockets, or most FIFOs and pipes.
565
566 When +L is specified without a following number, all link
567 counts will be listed. When -L is specified (the default), no
568 link counts will be listed.
569
570 When +L is followed by a number, only files having a link
571 count less than that number will be listed. (No number may
572 follow -L.) A specification of the form ``+L1'' will select
573 open files that have been unlinked. A specification of the
574 form ``+aL1 <file_system>'' will select unlinked open files on
575 the specified file system.
576
577 For other link count comparisons, use field output (-F) and a
578 post-processing script or program.
579
580 +|-m m specifies an alternate kernel memory file or activates mount
581 table supplement processing.
582
583 The option form -m m specifies a kernel memory file, m, in
584 place of /dev/kmem or /dev/mem - e.g., a crash dump file.
585
586 The option form +m requests that a mount supplement file be
587 written to the standard output file. All other options are
588 silently ignored.
589
590 There will be a line in the mount supplement file for each
591 mounted file system, containing the mounted file system direc‐
592 tory, followed by a single space, followed by the device num‐
593 ber in hexadecimal "0x" format - e.g.,
594
595 / 0x801
596
597 Lsof can use the mount supplement file to get device numbers
598 for file systems when it can't get them via stat(2) or
599 lstat(2).
600
601 The option form +m m identifies m as a mount supplement file.
602
603 Note: the +m and +m m options are not available for all sup‐
604 ported dialects. Check the output of lsof's -h or -? options
605 to see if the +m and +m m options are available.
606
607 +|-M Enables (+) or disables (-) the reporting of portmapper regis‐
608 trations for local TCP, UDP and UDPLITE ports, where port map‐
609 ping is supported. (See the last paragraph of this option
610 description for information about where portmapper registra‐
611 tion reporting is suported.)
612
613 The default reporting mode is set by the lsof builder with the
614 HASPMAPENABLED #define in the dialect's machine.h header file;
615 lsof is distributed with the HASPMAPENABLED #define deacti‐
616 vated, so portmapper reporting is disabled by default and must
617 be requested with +M. Specifying lsof's -h or -? option will
618 report the default mode. Disabling portmapper registration
619 when it is already disabled or enabling it when already
620 enabled is acceptable. When portmapper registration reporting
621 is enabled, lsof displays the portmapper registration (if any)
622 for local TCP, UDP or UDPLITE ports in square brackets immedi‐
623 ately following the port numbers or service names - e.g.,
624 ``:1234[name]'' or ``:name[100083]''. The registration infor‐
625 mation may be a name or number, depending on what the regis‐
626 tering program supplied to the portmapper when it registered
627 the port.
628
629 When portmapper registration reporting is enabled, lsof may
630 run a little more slowly or even become blocked when access to
631 the portmapper becomes congested or stopped. Reverse the
632 reporting mode to determine if portmapper registration report‐
633 ing is slowing or blocking lsof.
634
635 For purposes of portmapper registration reporting lsof consid‐
636 ers a TCP, UDP or UDPLITE port local if: it is found in the
637 local part of its containing kernel structure; or if it is
638 located in the foreign part of its containing kernel structure
639 and the local and foreign Internet addresses are the same; or
640 if it is located in the foreign part of its containing kernel
641 structure and the foreign Internet address is INADDR_LOOPBACK
642 (127.0.0.1). This rule may make lsof ignore some foreign
643 ports on machines with multiple interfaces when the foreign
644 Internet address is on a different interface from the local
645 one.
646
647 See the lsof FAQ (The FAQ section gives its location.) for
648 further discussion of portmapper registration reporting
649 issues.
650
651 Portmapper registration reporting is supported only on
652 dialects that have RPC header files. (Some Linux distribu‐
653 tions with GlibC 2.14 do not have them.) When portmapper reg‐
654 istration reporting is supported, the -h or -? help output
655 will show the +|-M option.
656
657 -n inhibits the conversion of network numbers to host names for
658 network files. Inhibiting conversion may make lsof run
659 faster. It is also useful when host name lookup is not work‐
660 ing properly.
661
662 -N selects the listing of NFS files.
663
664 -o directs lsof to display file offset at all times. It causes
665 the SIZE/OFF output column title to be changed to OFFSET.
666 Note: on some UNIX dialects lsof can't obtain accurate or con‐
667 sistent file offset information from its kernel data sources,
668 sometimes just for particular kinds of files (e.g., socket
669 files.) Consult the lsof FAQ (The FAQ section gives its loca‐
670 tion.) for more information.
671
672 The -o and -s options are mutually exclusive; they can't both
673 be specified. When neither is specified, lsof displays what‐
674 ever value - size or offset - is appropriate and available for
675 the type of the file.
676
677 -o o defines the number of decimal digits (o) to be printed after
678 the ``0t'' for a file offset before the form is switched to
679 ``0x...''. An o value of zero (unlimited) directs lsof to use
680 the ``0t'' form for all offset output.
681
682 This option does NOT direct lsof to display offset at all
683 times; specify -o (without a trailing number) to do that. -o
684 o only specifies the number of digits after ``0t'' in either
685 mixed size and offset or offset-only output. Thus, for exam‐
686 ple, to direct lsof to display offset at all times with a dec‐
687 imal digit count of 10, use:
688
689 -o -o 10
690 or
691 -oo10
692
693 The default number of digits allowed after ``0t'' is normally
694 8, but may have been changed by the lsof builder. Consult the
695 description of the -o o option in the output of the -h or -?
696 option to determine the default that is in effect.
697
698 -O directs lsof to bypass the strategy it uses to avoid being
699 blocked by some kernel operations - i.e., doing them in forked
700 child processes. See the BLOCKS AND TIMEOUTS and AVOIDING
701 KERNEL BLOCKS sections for more information on kernel opera‐
702 tions that may block lsof.
703
704 While use of this option will reduce lsof startup overhead, it
705 may also cause lsof to hang when the kernel doesn't respond to
706 a function. Use this option cautiously.
707
708 -p s excludes or selects the listing of files for the processes
709 whose optional process IDentification (PID) numbers are in the
710 comma-separated set s - e.g., ``123'' or ``123,^456''. (There
711 should be no spaces in the set.)
712
713 PID numbers that begin with `^' (negation) represent exclu‐
714 sions.
715
716 Multiple process ID numbers are joined in a single ORed set
717 before participating in AND option selection. However, PID
718 exclusions are applied without ORing or ANDing and take effect
719 before other selection criteria are applied.
720
721 -P inhibits the conversion of port numbers to port names for net‐
722 work files. Inhibiting the conversion may make lsof run a
723 little faster. It is also useful when port name lookup is not
724 working properly.
725
726 +|-r [t[m<fmt>]]
727 puts lsof in repeat mode. There lsof lists open files as
728 selected by other options, delays t seconds (default fifteen),
729 then repeats the listing, delaying and listing repetitively
730 until stopped by a condition defined by the prefix to the
731 option.
732
733 If the prefix is a `-', repeat mode is endless. Lsof must be
734 terminated with an interrupt or quit signal.
735
736 If the prefix is `+', repeat mode will end the first cycle no
737 open files are listed - and of course when lsof is stopped
738 with an interrupt or quit signal. When repeat mode ends
739 because no files are listed, the process exit code will be
740 zero if any open files were ever listed; one, if none were
741 ever listed.
742
743 Lsof marks the end of each listing: if field output is in
744 progress (the -F, option has been specified), the default
745 marker is `m'; otherwise the default marker is ``========''.
746 The marker is followed by a NL character.
747
748 The optional "m<fmt>" argument specifies a format for the
749 marker line. The <fmt> characters following `m' are inter‐
750 preted as a format specification to the strftime(3) function,
751 when both it and the localtime(3) function are available in
752 the dialect's C library. Consult the strftime(3) documenta‐
753 tion for what may appear in its format specification. Note
754 that when field output is requested with the -F option, <fmt>
755 cannot contain the NL format, ``%n''. Note also that when
756 <fmt> contains spaces or other characters that affect the
757 shell's interpretation of arguments, <fmt> must be quoted
758 appropriately.
759
760 Repeat mode reduces lsof startup overhead, so it is more effi‐
761 cient to use this mode than to call lsof repetitively from a
762 shell script, for example.
763
764 To use repeat mode most efficiently, accompany +|-r with spec‐
765 ification of other lsof selection options, so the amount of
766 kernel memory access lsof does will be kept to a minimum.
767 Options that filter at the process level - e.g., -c, -g, -p,
768 -u - are the most efficient selectors.
769
770 Repeat mode is useful when coupled with field output (see the
771 -F, option description) and a supervising awk or Perl script,
772 or a C program.
773
774 -R directs lsof to list the Parent Process IDentification number
775 in the PPID column.
776
777 -s [p:s] s alone directs lsof to display file size at all times. It
778 causes the SIZE/OFF output column title to be changed to SIZE.
779 If the file does not have a size, nothing is displayed.
780
781 The optional -s p:s form is available only for selected
782 dialects, and only when the -h or -? help output lists it.
783
784 When the optional form is available, the s may be followed by
785 a protocol name (p), either TCP or UDP, a colon (`:') and a
786 comma-separated protocol state name list, the option causes
787 open TCP and UDP files to be excluded if their state name(s)
788 are in the list (s) preceded by a `^'; or included if their
789 name(s) are not preceded by a `^'.
790
791 When an inclusion list is defined, only network files with
792 state names in the list will be present in the lsof output.
793 Thus, specifying one state name means that only network files
794 with that lone state name will be listed.
795
796 Case is unimportant in the protocol or state names, but there
797 may be no spaces and the colon (`:') separating the protocol
798 name (p) and the state name list (s) is required.
799
800 If only TCP and UDP files are to be listed, as controlled by
801 the specified exclusions and inclusions, the -i option must be
802 specified, too. If only a single protocol's files are to be
803 listed, add its name as an argument to the -i option.
804
805 For example, to list only network files with TCP state LISTEN,
806 use:
807
808 -iTCP -sTCP:LISTEN
809
810 Or, for example, to list network files with all UDP states
811 except Idle, use:
812
813 -iUDP -sUDP:Idle
814
815 State names vary with UNIX dialects, so it's not possible to
816 provide a complete list. Some common TCP state names are:
817 CLOSED, IDLE, BOUND, LISTEN, ESTABLISHED, SYN_SENT, SYN_RCDV,
818 ESTABLISHED, CLOSE_WAIT, FIN_WAIT1, CLOSING, LAST_ACK,
819 FIN_WAIT_2, and TIME_WAIT. Two common UDP state names are
820 Unbound and Idle.
821
822 See the lsof FAQ (The FAQ section gives its location.) for
823 more information on how to use protocol state exclusion and
824 inclusion, including examples.
825
826 The -o (without a following decimal digit count) and -s option
827 (without a following protocol and state name list) are mutu‐
828 ally exclusive; they can't both be specified. When neither is
829 specified, lsof displays whatever value - size or offset - is
830 appropriate and available for the type of file.
831
832 Since some types of files don't have true sizes - sockets,
833 FIFOs, pipes, etc. - lsof displays for their sizes the content
834 amounts in their associated kernel buffers, if possible.
835
836 -S [t] specifies an optional time-out seconds value for kernel func‐
837 tions - lstat(2), readlink(2), and stat(2) - that might other‐
838 wise deadlock. The minimum for t is two; the default, fif‐
839 teen; when no value is specified, the default is used.
840
841 See the BLOCKS AND TIMEOUTS section for more information.
842
843 -T [t] controls the reporting of some TCP/TPI information, also
844 reported by netstat(1), following the network addresses. In
845 normal output the information appears in parentheses, each
846 item except TCP or TPI state name identified by a keyword,
847 followed by `=', separated from others by a single space:
848
849 <TCP or TPI state name>
850 QR=<read queue length>
851 QS=<send queue length>
852 SO=<socket options and values>
853 SS=<socket states>
854 TF=<TCP flags and values>
855 WR=<window read length>
856 WW=<window write length>
857
858 Not all values are reported for all UNIX dialects. Items val‐
859 ues (when available) are reported after the item name and '='.
860
861 When the field output mode is in effect (See OUTPUT FOR OTHER
862 PROGRAMS.) each item appears as a field with a `T' leading
863 character.
864
865 -T with no following key characters disables TCP/TPI informa‐
866 tion reporting.
867
868 -T with following characters selects the reporting of specific
869 TCP/TPI information:
870
871 f selects reporting of socket options,
872 states and values, and TCP flags and
873 values.
874 q selects queue length reporting.
875 s selects connection state reporting.
876 w selects window size reporting.
877
878 Not all selections are enabled for some UNIX dialects. State
879 may be selected for all dialects and is reported by default.
880 The -h or -? help output for the -T option will show what
881 selections may be used with the UNIX dialect.
882
883 When -T is used to select information - i.e., it is followed
884 by one or more selection characters - the displaying of state
885 is disabled by default, and it must be explicitly selected
886 again in the characters following -T. (In effect, then, the
887 default is equivalent to -Ts.) For example, if queue lengths
888 and state are desired, use -Tqs.
889
890 Socket options, socket states, some socket values, TCP flags
891 and one TCP value may be reported (when available in the UNIX
892 dialect) in the form of the names that commonly appear after
893 SO_, so_, SS_, TCP_ and TF_ in the dialect's header files -
894 most often <sys/socket.h>, <sys/socketvar.h> and
895 <netinet/tcp_var.h>. Consult those header files for the mean‐
896 ing of the flags, options, states and values.
897
898 ``SO='' precedes socket options and values; ``SS='', socket
899 states; and ``TF='', TCP flags and values.
900
901 If a flag or option has a value, the value will follow an '='
902 and the name -- e.g., ``SO=LINGER=5'', ``SO=QLIM=5'',
903 ``TF=MSS=512''. The following seven values may be reported:
904
905 Name
906 Reported Description (Common Symbol)
907
908 KEEPALIVE keep alive time (SO_KEEPALIVE)
909 LINGER linger time (SO_LINGER)
910 MSS maximum segment size (TCP_MAXSEG)
911 PQLEN partial listen queue connections
912 QLEN established listen queue connections
913 QLIM established listen queue limit
914 RCVBUF receive buffer length (SO_RCVBUF)
915 SNDBUF send buffer length (SO_SNDBUF)
916
917 Details on what socket options and values, socket states, and
918 TCP flags and values may be displayed for particular UNIX
919 dialects may be found in the answer to the ``Why doesn't lsof
920 report socket options, socket states, and TCP flags and values
921 for my dialect?'' and ``Why doesn't lsof report the partial
922 listen queue connection count for my dialect?'' questions in
923 the lsof FAQ (The FAQ section gives its location.)
924
925 -t specifies that lsof should produce terse output with process
926 identifiers only and no header - e.g., so that the output may
927 be piped to kill(1). -t selects the -w option.
928
929 -u s selects the listing of files for the user whose login names or
930 user ID numbers are in the comma-separated set s - e.g.,
931 ``abe'', or ``548,root''. (There should be no spaces in the
932 set.)
933
934 Multiple login names or user ID numbers are joined in a single
935 ORed set before participating in AND option selection.
936
937 If a login name or user ID is preceded by a `^', it becomes a
938 negation - i.e., files of processes owned by the login name or
939 user ID will never be listed. A negated login name or user ID
940 selection is neither ANDed nor ORed with other selections; it
941 is applied before all other selections and absolutely excludes
942 the listing of the files of the process. For example, to
943 direct lsof to exclude the listing of files belonging to root
944 processes, specify ``-u^root'' or ``-u^0''.
945
946 -U selects the listing of UNIX domain socket files.
947
948 -v selects the listing of lsof version information, including:
949 revision number; when the lsof binary was constructed; who
950 constructed the binary and where; the name of the compiler
951 used to construct the lsof binary; the version number of the
952 compiler when readily available; the compiler and loader flags
953 used to construct the lsof binary; and system information,
954 typically the output of uname's -a option.
955
956 -V directs lsof to indicate the items it was asked to list and
957 failed to find - command names, file names, Internet addresses
958 or files, login names, NFS files, PIDs, PGIDs, and UIDs.
959
960 When other options are ANDed to search options, or com‐
961 pile-time options restrict the listing of some files, lsof may
962 not report that it failed to find a search item when an ANDed
963 option or compile-time option prevents the listing of the open
964 file containing the located search item.
965
966 For example, ``lsof -V -iTCP@foobar -a -d 999'' may not report
967 a failure to locate open files at ``TCP@foobar'' and may not
968 list any, if none have a file descriptor number of 999. A
969 similar situation arises when HASSECURITY and HASNOSOCKSECU‐
970 RITY are defined at compile time and they prevent the listing
971 of open files.
972
973 +|-w Enables (+) or disables (-) the suppression of warning mes‐
974 sages.
975
976 The lsof builder may choose to have warning messages disabled
977 or enabled by default. The default warning message state is
978 indicated in the output of the -h or -? option. Disabling
979 warning messages when they are already disabled or enabling
980 them when already enabled is acceptable.
981
982 The -t option selects the -w option.
983
984 -x [fl] may accompany the +d and +D options to direct their processing
985 to cross over symbolic links and|or file system mount points
986 encountered when scanning the directory (+d) or directory tree
987 (+D).
988
989 If -x is specified by itself without a following parameter,
990 cross-over processing of both symbolic links and file system
991 mount points is enabled. Note that when -x is specified with‐
992 out a parameter, the next argument must begin with '-' or '+'.
993
994 The optional 'f' parameter enables file system mount point
995 cross-over processing; 'l', symbolic link cross-over process‐
996 ing.
997
998 The -x option may not be supplied without also supplying a +d
999 or +D option.
1000
1001 -X This is a dialect-specific option.
1002
1003 AIX:
1004 This IBM AIX RISC/System 6000 option requests the reporting of
1005 executed text file and shared library references.
1006
1007 WARNING: because this option uses the kernel readx() function,
1008 its use on a busy AIX system might cause an application
1009 process to hang so completely that it can neither be killed
1010 nor stopped. I have never seen this happen or had a report of
1011 its happening, but I think there is a remote possibility it
1012 could happen.
1013
1014 By default use of readx() is disabled. On AIX 5L and above
1015 lsof may need setuid-root permission to perform the actions
1016 this option requests.
1017
1018 The lsof builder may specify that the -X option be restricted
1019 to processes whose real UID is root. If that has been done,
1020 the -X option will not appear in the -h or -? help output
1021 unless the real UID of the lsof process is root. The default
1022 lsof distribution allows any UID to specify -X, so by default
1023 it will appear in the help output.
1024
1025 When AIX readx() use is disabled, lsof may not be able to
1026 report information for all text and loader file references,
1027 but it may also avoid exacerbating an AIX kernel directory
1028 search kernel error, known as the Stale Segment ID bug.
1029
1030 The readx() function, used by lsof or any other program to
1031 access some sections of kernel virtual memory, can trigger the
1032 Stale Segment ID bug. It can cause the kernel's dir_search()
1033 function to believe erroneously that part of an in-memory copy
1034 of a file system directory has been zeroed. Another applica‐
1035 tion process, distinct from lsof, asking the kernel to search
1036 the directory - e.g., by using open(2) - can cause
1037 dir_search() to loop forever, thus hanging the application
1038 process.
1039
1040 Consult the lsof FAQ (The FAQ section gives its location.)
1041 and the 00README file of the lsof distribution for a more com‐
1042 plete description of the Stale Segment ID bug, its APAR, and
1043 methods for defining readx() use when compiling lsof.
1044
1045 Linux:
1046 This Linux option requests that lsof skip the reporting of
1047 information on all open TCP, UDP and UDPLITE IPv4 and IPv6
1048 files.
1049
1050 This Linux option is most useful when the system has an
1051 extremely large number of open TCP, UDP and UDPLITE files, the
1052 processing of whose information in the /proc/net/tcp* and
1053 /proc/net/udp* files would take lsof a long time, and whose
1054 reporting is not of interest.
1055
1056 Use this option with care and only when you are sure that the
1057 information you want lsof to display isn't associated with
1058 open TCP, UDP or UDPLITE socket files.
1059
1060 Solaris 10 and above:
1061 This Solaris 10 and above option requests the reporting of
1062 cached paths for files that have been deleted - i.e., removed
1063 with rm(1) or unlink(2).
1064
1065 The cached path is followed by the string `` (deleted)'' to
1066 indicate that the path by which the file was opened has been
1067 deleted.
1068
1069 Because intervening changes made to the path - i.e., renames
1070 with mv(1) or rename(2) - are not recorded in the cached path,
1071 what lsof reports is only the path by which the file was
1072 opened, not its possibly different final path.
1073
1074 -z [z] specifies how Solaris 10 and higher zone information is to be
1075 handled.
1076
1077 Without a following argument - e.g., NO z - the option speci‐
1078 fies that zone names are to be listed in the ZONE output col‐
1079 umn.
1080
1081 The -z option may be followed by a zone name, z. That causes
1082 lsof to list only open files for processes in that zone. Mul‐
1083 tiple -z z option and argument pairs may be specified to form
1084 a list of named zones. Any open file of any process in any of
1085 the zones will be listed, subject to other conditions speci‐
1086 fied by other options and arguments.
1087
1088 -Z [Z] specifies how SELinux security contexts are to be handled. It
1089 and 'Z' field output character support are inhibited when
1090 SELinux is disabled in the running Linux kernel. See OUTPUT
1091 FOR OTHER PROGRAMS for more information on the 'Z' field out‐
1092 put character.
1093
1094 Without a following argument - e.g., NO Z - the option speci‐
1095 fies that security contexts are to be listed in the SECU‐
1096 RITY-CONTEXT output column.
1097
1098 The -Z option may be followed by a wildcard security context
1099 name, Z. That causes lsof to list only open files for pro‐
1100 cesses in that security context. Multiple -Z Z option and
1101 argument pairs may be specified to form a list of security
1102 contexts. Any open file of any process in any of the security
1103 contexts will be listed, subject to other conditions specified
1104 by other options and arguments. Note that Z can be A:B:C or
1105 *:B:C or A:B:* or *:*:C to match against the A:B:C context.
1106
1107 -- The double minus sign option is a marker that signals the end
1108 of the keyed options. It may be used, for example, when the
1109 first file name begins with a minus sign. It may also be used
1110 when the absence of a value for the last keyed option must be
1111 signified by the presence of a minus sign in the following
1112 option and before the start of the file names.
1113
1114 names These are path names of specific files to list. Symbolic
1115 links are resolved before use. The first name may be sepa‐
1116 rated from the preceding options with the ``--'' option.
1117
1118 If a name is the mounted-on directory of a file system or the
1119 device of the file system, lsof will list all the files open
1120 on the file system. To be considered a file system, the name
1121 must match a mounted-on directory name in mount(8) output, or
1122 match the name of a block device associated with a mounted-on
1123 directory name. The +|-f option may be used to force lsof to
1124 consider a name a file system identifier (+f) or a simple file
1125 (-f).
1126
1127 If name is a path to a directory that is not the mounted-on
1128 directory name of a file system, it is treated just as a regu‐
1129 lar file is treated - i.e., its listing is restricted to pro‐
1130 cesses that have it open as a file or as a process-specific
1131 directory, such as the root or current working directory. To
1132 request that lsof look for open files inside a directory name,
1133 use the +d s and +D D options.
1134
1135 If a name is the base name of a family of multiplexed files -
1136 e. g, AIX's /dev/pt[cs] - lsof will list all the associated
1137 multiplexed files on the device that are open - e.g.,
1138 /dev/pt[cs]/1, /dev/pt[cs]/2, etc.
1139
1140 If a name is a UNIX domain socket name, lsof will usually
1141 search for it by the characters of the name alone - exactly as
1142 it is specified and is recorded in the kernel socket struc‐
1143 ture. (See the next paragraph for an exception to that rule
1144 for Linux.) Specifying a relative path - e.g., ./file - in
1145 place of the file's absolute path - e.g., /tmp/file - won't
1146 work because lsof must match the characters you specify with
1147 what it finds in the kernel UNIX domain socket structures.
1148
1149 If a name is a Linux UNIX domain socket name, in one case lsof
1150 is able to search for it by its device and inode number,
1151 allowing name to be a relative path. The case requires that
1152 the absolute path -- i.e., one beginning with a slash ('/') be
1153 used by the process that created the socket, and hence be
1154 stored in the /proc/net/unix file; and it requires that lsof
1155 be able to obtain the device and node numbers of both the
1156 absolute path in /proc/net/unix and name via successful
1157 stat(2) system calls. When those conditions are met, lsof
1158 will be able to search for the UNIX domain socket when some
1159 path to it is is specified in name. Thus, for example, if the
1160 path is /dev/log, and an lsof search is initiated when the
1161 working directory is /dev, then name could be ./log.
1162
1163 If a name is none of the above, lsof will list any open files
1164 whose device and inode match that of the specified path name.
1165
1166 If you have also specified the -b option, the only names you
1167 may safely specify are file systems for which your mount table
1168 supplies alternate device numbers. See the AVOIDING KERNEL
1169 BLOCKS and ALTERNATE DEVICE NUMBERS sections for more informa‐
1170 tion.
1171
1172 Multiple file names are joined in a single ORed set before
1173 participating in AND option selection.
1174
1176 Lsof supports the recognition of AFS files for these dialects (and AFS
1177 versions):
1178
1179 AIX 4.1.4 (AFS 3.4a)
1180 HP-UX 9.0.5 (AFS 3.4a)
1181 Linux 1.2.13 (AFS 3.3)
1182 Solaris 2.[56] (AFS 3.4a)
1183
1184 It may recognize AFS files on other versions of these dialects, but has
1185 not been tested there. Depending on how AFS is implemented, lsof may
1186 recognize AFS files in other dialects, or may have difficulties recog‐
1187 nizing AFS files in the supported dialects.
1188
1189 Lsof may have trouble identifying all aspects of AFS files in supported
1190 dialects when AFS kernel support is implemented via dynamic modules
1191 whose addresses do not appear in the kernel's variable name list. In
1192 that case, lsof may have to guess at the identity of AFS files, and
1193 might not be able to obtain volume information from the kernel that is
1194 needed for calculating AFS volume node numbers. When lsof can't com‐
1195 pute volume node numbers, it reports blank in the NODE column.
1196
1197 The -A A option is available in some dialect implementations of lsof
1198 for specifying the name list file where dynamic module kernel addresses
1199 may be found. When this option is available, it will be listed in the
1200 lsof help output, presented in response to the -h or -?
1201
1202 See the lsof FAQ (The FAQ section gives its location.) for more infor‐
1203 mation about dynamic modules, their symbols, and how they affect lsof
1204 options.
1205
1206 Because AFS path lookups don't seem to participate in the kernel's name
1207 cache operations, lsof can't identify path name components for AFS
1208 files.
1209
1211 Lsof has three features that may cause security concerns. First, its
1212 default compilation mode allows anyone to list all open files with it.
1213 Second, by default it creates a user-readable and user-writable device
1214 cache file in the home directory of the real user ID that executes
1215 lsof. (The list-all-open-files and device cache features may be dis‐
1216 abled when lsof is compiled.) Third, its -k and -m options name alter‐
1217 nate kernel name list or memory files.
1218
1219 Restricting the listing of all open files is controlled by the com‐
1220 pile-time HASSECURITY and HASNOSOCKSECURITY options. When HASSECURITY
1221 is defined, lsof will allow only the root user to list all open files.
1222 The non-root user may list only open files of processes with the same
1223 user IDentification number as the real user ID number of the lsof
1224 process (the one that its user logged on with).
1225
1226 However, if HASSECURITY and HASNOSOCKSECURITY are both defined, anyone
1227 may list open socket files, provided they are selected with the -i
1228 option.
1229
1230 When HASSECURITY is not defined, anyone may list all open files.
1231
1232 Help output, presented in response to the -h or -? option, gives the
1233 status of the HASSECURITY and HASNOSOCKSECURITY definitions.
1234
1235 See the Security section of the 00README file of the lsof distribution
1236 for information on building lsof with the HASSECURITY and HASNOSOCKSE‐
1237 CURITY options enabled.
1238
1239 Creation and use of a user-readable and user-writable device cache file
1240 is controlled by the compile-time HASDCACHE option. See the DEVICE
1241 CACHE FILE section and the sections that follow it for details on how
1242 its path is formed. For security considerations it is important to
1243 note that in the default lsof distribution, if the real user ID under
1244 which lsof is executed is root, the device cache file will be written
1245 in root's home directory - e.g., / or /root. When HASDCACHE is not
1246 defined, lsof does not write or attempt to read a device cache file.
1247
1248 When HASDCACHE is defined, the lsof help output, presented in response
1249 to the -h, -D?, or -? options, will provide device cache file handling
1250 information. When HASDCACHE is not defined, the -h or -? output will
1251 have no -D option description.
1252
1253 Before you decide to disable the device cache file feature - enabling
1254 it improves the performance of lsof by reducing the startup overhead of
1255 examining all the nodes in /dev (or /devices) - read the discussion of
1256 it in the 00DCACHE file of the lsof distribution and the lsof FAQ (The
1257 FAQ section gives its location.)
1258
1259 WHEN IN DOUBT, YOU CAN TEMPORARILY DISABLE THE USE OF THE DEVICE CACHE
1260 FILE WITH THE -Di OPTION.
1261
1262 When lsof user declares alternate kernel name list or memory files with
1263 the -k and -m options, lsof checks the user's authority to read them
1264 with access(2). This is intended to prevent whatever special power
1265 lsof's modes might confer on it from letting it read files not normally
1266 accessible via the authority of the real user ID.
1267
1269 This section describes the information lsof lists for each open file.
1270 See the OUTPUT FOR OTHER PROGRAMS section for additional information on
1271 output that can be processed by another program.
1272
1273 Lsof only outputs printable (declared so by isprint(3)) 8 bit charac‐
1274 ters. Non-printable characters are printed in one of three forms: the
1275 C ``\[bfrnt]'' form; the control character `^' form (e.g., ``^@''); or
1276 hexadecimal leading ``\x'' form (e.g., ``\xab''). Space is non-print‐
1277 able in the COMMAND column (``\x20'') and printable elsewhere.
1278
1279 For some dialects - if HASSETLOCALE is defined in the dialect's
1280 machine.h header file - lsof will print the extended 8 bit characters
1281 of a language locale. The lsof process must be supplied a language
1282 locale environment variable (e.g., LANG) whose value represents a known
1283 language locale in which the extended characters are considered print‐
1284 able by isprint(3). Otherwise lsof considers the extended characters
1285 non-printable and prints them according to its rules for non-printable
1286 characters, stated above. Consult your dialect's setlocale(3) man page
1287 for the names of other environment variables that may be used in place
1288 of LANG - e.g., LC_ALL, LC_CTYPE, etc.
1289
1290 Lsof's language locale support for a dialect also covers wide charac‐
1291 ters - e.g., UTF-8 - when HASSETLOCALE and HASWIDECHAR are defined in
1292 the dialect's machine.h header file, and when a suitable language
1293 locale has been defined in the appropriate environment variable for the
1294 lsof process. Wide characters are printable under those conditions if
1295 iswprint(3) reports them to be. If HASSETLOCALE, HASWIDECHAR and a
1296 suitable language locale aren't defined, or if iswprint(3) reports wide
1297 characters that aren't printable, lsof considers the wide characters
1298 non-printable and prints each of their 8 bits according to its rules
1299 for non-printable characters, stated above.
1300
1301 Consult the answers to the "Language locale support" questions in the
1302 lsof FAQ (The FAQ section gives its location.) for more information.
1303
1304 Lsof dynamically sizes the output columns each time it runs, guarantee‐
1305 ing that each column is a minimum size. It also guarantees that each
1306 column is separated from its predecessor by at least one space.
1307
1308 COMMAND contains the first nine characters of the name of the UNIX
1309 command associated with the process. If a non-zero w value
1310 is specified to the +c w option, the column contains the
1311 first w characters of the name of the UNIX command associ‐
1312 ated with the process up to the limit of characters supplied
1313 to lsof by the UNIX dialect. (See the description of the +c
1314 w command or the lsof FAQ for more information. The FAQ
1315 section gives its location.)
1316
1317 If w is less than the length of the column title, ``COM‐
1318 MAND'', it will be raised to that length.
1319
1320 If a zero w value is specified to the +c w option, the col‐
1321 umn contains all the characters of the name of the UNIX com‐
1322 mand associated with the process.
1323
1324 All command name characters maintained by the kernel in its
1325 structures are displayed in field output when the command
1326 name descriptor (`c') is specified. See the OUTPUT FOR
1327 OTHER COMMANDS section for information on selecting field
1328 output and the associated command name descriptor.
1329
1330 PID is the Process IDentification number of the process.
1331
1332 TID is the task (thread) IDentification number, if task (thread)
1333 reporting is supported by the dialect and a task (thread) is
1334 being listed. (If help output - i.e., the output of the -h
1335 or -? options - shows this option, then task (thread)
1336 reporting is supported by the dialect.)
1337
1338 A blank TID column in Linux indicates a process - i.e., a
1339 non-task.
1340
1341 ZONE is the Solaris 10 and higher zone name. This column must be
1342 selected with the -z option.
1343
1344 SECURITY-CONTEXT
1345 is the SELinux security context. This column must be
1346 selected with the -Z option. Note that the -Z option is
1347 inhibited when SELinux is disabled in the running Linux ker‐
1348 nel.
1349
1350 PPID is the Parent Process IDentification number of the process.
1351 It is only displayed when the -R option has been specified.
1352
1353 PGID is the process group IDentification number associated with
1354 the process. It is only displayed when the -g option has
1355 been specified.
1356
1357 USER is the user ID number or login name of the user to whom the
1358 process belongs, usually the same as reported by ps(1).
1359 However, on Linux USER is the user ID number or login that
1360 owns the directory in /proc where lsof finds information
1361 about the process. Usually that is the same value reported
1362 by ps(1), but may differ when the process has changed its
1363 effective user ID. (See the -l option description for
1364 information on when a user ID number or login name is dis‐
1365 played.)
1366
1367 FD is the File Descriptor number of the file or:
1368
1369 cwd current working directory;
1370 Lnn library references (AIX);
1371 err FD information error (see NAME column);
1372 jld jail directory (FreeBSD);
1373 ltx shared library text (code and data);
1374 Mxx hex memory-mapped type number xx.
1375 m86 DOS Merge mapped file;
1376 mem memory-mapped file;
1377 mmap memory-mapped device;
1378 pd parent directory;
1379 rtd root directory;
1380 tr kernel trace file (OpenBSD);
1381 txt program text (code and data);
1382 v86 VP/ix mapped file;
1383
1384 FD is followed by one of these characters, describing the
1385 mode under which the file is open:
1386
1387 r for read access;
1388 w for write access;
1389 u for read and write access;
1390 space if mode unknown and no lock
1391 character follows;
1392 `-' if mode unknown and lock
1393 character follows.
1394
1395 The mode character is followed by one of these lock charac‐
1396 ters, describing the type of lock applied to the file:
1397
1398 N for a Solaris NFS lock of unknown type;
1399 r for read lock on part of the file;
1400 R for a read lock on the entire file;
1401 w for a write lock on part of the file;
1402 W for a write lock on the entire file;
1403 u for a read and write lock of any length;
1404 U for a lock of unknown type;
1405 x for an SCO OpenServer Xenix lock on part of the
1406 file;
1407 X for an SCO OpenServer Xenix lock on the entire
1408 file;
1409 space if there is no lock.
1410
1411 See the LOCKS section for more information on the lock
1412 information character.
1413
1414 The FD column contents constitutes a single field for pars‐
1415 ing in post-processing scripts.
1416
1417 TYPE is the type of the node associated with the file - e.g.,
1418 GDIR, GREG, VDIR, VREG, etc.
1419
1420 or ``IPv4'' for an IPv4 socket;
1421
1422 or ``IPv6'' for an open IPv6 network file - even if its
1423 address is IPv4, mapped in an IPv6 address;
1424
1425 or ``ax25'' for a Linux AX.25 socket;
1426
1427 or ``inet'' for an Internet domain socket;
1428
1429 or ``lla'' for a HP-UX link level access file;
1430
1431 or ``rte'' for an AF_ROUTE socket;
1432
1433 or ``sock'' for a socket of unknown domain;
1434
1435 or ``unix'' for a UNIX domain socket;
1436
1437 or ``x.25'' for an HP-UX x.25 socket;
1438
1439 or ``BLK'' for a block special file;
1440
1441 or ``CHR'' for a character special file;
1442
1443 or ``DEL'' for a Linux map file that has been deleted;
1444
1445 or ``DIR'' for a directory;
1446
1447 or ``DOOR'' for a VDOOR file;
1448
1449 or ``FIFO'' for a FIFO special file;
1450
1451 or ``KQUEUE'' for a BSD style kernel event queue file;
1452
1453 or ``LINK'' for a symbolic link file;
1454
1455 or ``MPB'' for a multiplexed block file;
1456
1457 or ``MPC'' for a multiplexed character file;
1458
1459 or ``NOFD'' for a Linux /proc/<PID>/fd directory that can't
1460 be opened -- the directory path appears in the NAME column,
1461 followed by an error message;
1462
1463 or ``PAS'' for a /proc/as file;
1464
1465 or ``PAXV'' for a /proc/auxv file;
1466
1467 or ``PCRE'' for a /proc/cred file;
1468
1469 or ``PCTL'' for a /proc control file;
1470
1471 or ``PCUR'' for the current /proc process;
1472
1473 or ``PCWD'' for a /proc current working directory;
1474
1475 or ``PDIR'' for a /proc directory;
1476
1477 or ``PETY'' for a /proc executable type (etype);
1478
1479 or ``PFD'' for a /proc file descriptor;
1480
1481 or ``PFDR'' for a /proc file descriptor directory;
1482
1483 or ``PFIL'' for an executable /proc file;
1484
1485 or ``PFPR'' for a /proc FP register set;
1486
1487 or ``PGD'' for a /proc/pagedata file;
1488
1489 or ``PGID'' for a /proc group notifier file;
1490
1491 or ``PIPE'' for pipes;
1492
1493 or ``PLC'' for a /proc/lwpctl file;
1494
1495 or ``PLDR'' for a /proc/lpw directory;
1496
1497 or ``PLDT'' for a /proc/ldt file;
1498
1499 or ``PLPI'' for a /proc/lpsinfo file;
1500
1501 or ``PLST'' for a /proc/lstatus file;
1502
1503 or ``PLU'' for a /proc/lusage file;
1504
1505 or ``PLWG'' for a /proc/gwindows file;
1506
1507 or ``PLWI'' for a /proc/lwpsinfo file;
1508
1509 or ``PLWS'' for a /proc/lwpstatus file;
1510
1511 or ``PLWU'' for a /proc/lwpusage file;
1512
1513 or ``PLWX'' for a /proc/xregs file'
1514
1515 or ``PMAP'' for a /proc map file (map);
1516
1517 or ``PMEM'' for a /proc memory image file;
1518
1519 or ``PNTF'' for a /proc process notifier file;
1520
1521 or ``POBJ'' for a /proc/object file;
1522
1523 or ``PODR'' for a /proc/object directory;
1524
1525 or ``POLP'' for an old format /proc light weight process
1526 file;
1527
1528 or ``POPF'' for an old format /proc PID file;
1529
1530 or ``POPG'' for an old format /proc page data file;
1531
1532 or ``PORT'' for a SYSV named pipe;
1533
1534 or ``PREG'' for a /proc register file;
1535
1536 or ``PRMP'' for a /proc/rmap file;
1537
1538 or ``PRTD'' for a /proc root directory;
1539
1540 or ``PSGA'' for a /proc/sigact file;
1541
1542 or ``PSIN'' for a /proc/psinfo file;
1543
1544 or ``PSTA'' for a /proc status file;
1545
1546 or ``PSXSEM'' for a POSIX semaphore file;
1547
1548 or ``PSXSHM'' for a POSIX shared memory file;
1549
1550 or ``PUSG'' for a /proc/usage file;
1551
1552 or ``PW'' for a /proc/watch file;
1553
1554 or ``PXMP'' for a /proc/xmap file;
1555
1556 or ``REG'' for a regular file;
1557
1558 or ``SMT'' for a shared memory transport file;
1559
1560 or ``STSO'' for a stream socket;
1561
1562 or ``UNNM'' for an unnamed type file;
1563
1564 or ``XNAM'' for an OpenServer Xenix special file of unknown
1565 type;
1566
1567 or ``XSEM'' for an OpenServer Xenix semaphore file;
1568
1569 or ``XSD'' for an OpenServer Xenix shared data file;
1570
1571 or the four type number octets if the corresponding name
1572 isn't known.
1573
1574 FILE-ADDR contains the kernel file structure address when f has been
1575 specified to +f;
1576
1577 FCT contains the file reference count from the kernel file
1578 structure when c has been specified to +f;
1579
1580 FILE-FLAG when g or G has been specified to +f, this field contains
1581 the contents of the f_flag[s] member of the kernel file
1582 structure and the kernel's per-process open file flags (if
1583 available); `G' causes them to be displayed in hexadecimal;
1584 `g', as short-hand names; two lists may be displayed with
1585 entries separated by commas, the lists separated by a semi‐
1586 colon (`;'); the first list may contain short-hand names for
1587 f_flag[s] values from the following table:
1588
1589 AIO asynchronous I/O (e.g., FAIO)
1590 AP append
1591 ASYN asynchronous I/O (e.g., FASYNC)
1592 BAS block, test, and set in use
1593 BKIU block if in use
1594 BL use block offsets
1595 BSK block seek
1596 CA copy avoid
1597 CIO concurrent I/O
1598 CLON clone
1599 CLRD CL read
1600 CR create
1601 DF defer
1602 DFI defer IND
1603 DFLU data flush
1604 DIR direct
1605 DLY delay
1606 DOCL do clone
1607 DSYN data-only integrity
1608 DTY must be a directory
1609 EVO event only
1610 EX open for exec
1611 EXCL exclusive open
1612 FSYN synchronous writes
1613 GCDF defer during unp_gc() (AIX)
1614 GCMK mark during unp_gc() (AIX)
1615 GTTY accessed via /dev/tty
1616 HUP HUP in progress
1617 KERN kernel
1618 KIOC kernel-issued ioctl
1619 LCK has lock
1620 LG large file
1621 MBLK stream message block
1622 MK mark
1623 MNT mount
1624 MSYN multiplex synchronization
1625 NATM don't update atime
1626 NB non-blocking I/O
1627 NBDR no BDRM check
1628 NBIO SYSV non-blocking I/O
1629 NBF n-buffering in effect
1630 NC no cache
1631 ND no delay
1632 NDSY no data synchronization
1633 NET network
1634 NFLK don't follow links
1635 NMFS NM file system
1636 NOTO disable background stop
1637 NSH no share
1638 NTTY no controlling TTY
1639 OLRM OLR mirror
1640 PAIO POSIX asynchronous I/O
1641 PP POSIX pipe
1642 R read
1643 RC file and record locking cache
1644 REV revoked
1645 RSH shared read
1646 RSYN read synchronization
1647 RW read and write access
1648 SL shared lock
1649 SNAP cooked snapshot
1650 SOCK socket
1651 SQSH Sequent shared set on open
1652 SQSV Sequent SVM set on open
1653 SQR Sequent set repair on open
1654 SQS1 Sequent full shared open
1655 SQS2 Sequent partial shared open
1656 STPI stop I/O
1657 SWR synchronous read
1658 SYN file integrity while writing
1659 TCPM avoid TCP collision
1660 TR truncate
1661 W write
1662 WKUP parallel I/O synchronization
1663 WTG parallel I/O synchronization
1664 VH vhangup pending
1665 VTXT virtual text
1666 XL exclusive lock
1667
1668 this list of names was derived from F* #define's in dialect
1669 header files <fcntl.h>, <linux</fs.h>, <sys/fcntl.c>,
1670 <sys/fcntlcom.h>, and <sys/file.h>; see the lsof.h header
1671 file for a list showing the correspondence between the above
1672 short-hand names and the header file definitions;
1673
1674 the second list (after the semicolon) may contain short-hand
1675 names for kernel per-process open file flags from this ta‐
1676 ble:
1677
1678 ALLC allocated
1679 BR the file has been read
1680 BHUP activity stopped by SIGHUP
1681 BW the file has been written
1682 CLSG closing
1683 CX close-on-exec (see fcntl(F_SETFD))
1684 LCK lock was applied
1685 MP memory-mapped
1686 OPIP open pending - in progress
1687 RSVW reserved wait
1688 SHMT UF_FSHMAT set (AIX)
1689 USE in use (multi-threaded)
1690
1691 NODE-ID (or INODE-ADDR for some dialects) contains a unique identi‐
1692 fier for the file node (usually the kernel vnode or inode
1693 address, but also occasionally a concatenation of device and
1694 node number) when n has been specified to +f;
1695
1696 DEVICE contains the device numbers, separated by commas, for a
1697 character special, block special, regular, directory or NFS
1698 file;
1699
1700 or ``memory'' for a memory file system node under Tru64
1701 UNIX;
1702
1703 or the address of the private data area of a Solaris socket
1704 stream;
1705
1706 or a kernel reference address that identifies the file (The
1707 kernel reference address may be used for FIFO's, for exam‐
1708 ple.);
1709
1710 or the base address or device name of a Linux AX.25 socket
1711 device.
1712
1713 Usually only the lower thirty two bits of Tru64 UNIX kernel
1714 addresses are displayed.
1715
1716 SIZE, SIZE/OFF, or OFFSET
1717 is the size of the file or the file offset in bytes. A
1718 value is displayed in this column only if it is available.
1719 Lsof displays whatever value - size or offset - is appropri‐
1720 ate for the type of the file and the version of lsof.
1721
1722 On some UNIX dialects lsof can't obtain accurate or consis‐
1723 tent file offset information from its kernel data sources,
1724 sometimes just for particular kinds of files (e.g., socket
1725 files.) In other cases, files don't have true sizes - e.g.,
1726 sockets, FIFOs, pipes - so lsof displays for their sizes the
1727 content amounts it finds in their kernel buffer descriptors
1728 (e.g., socket buffer size counts or TCP/IP window sizes.)
1729 Consult the lsof FAQ (The FAQ section gives its location.)
1730 for more information.
1731
1732 The file size is displayed in decimal; the offset is nor‐
1733 mally displayed in decimal with a leading ``0t'' if it con‐
1734 tains 8 digits or less; in hexadecimal with a leading ``0x''
1735 if it is longer than 8 digits. (Consult the -o o option
1736 description for information on when 8 might default to some
1737 other value.)
1738
1739 Thus the leading ``0t'' and ``0x'' identify an offset when
1740 the column may contain both a size and an offset (i.e., its
1741 title is SIZE/OFF).
1742
1743 If the -o option is specified, lsof always displays the file
1744 offset (or nothing if no offset is available) and labels the
1745 column OFFSET. The offset always begins with ``0t'' or
1746 ``0x'' as described above.
1747
1748 The lsof user can control the switch from ``0t'' to ``0x''
1749 with the -o o option. Consult its description for more
1750 information.
1751
1752 If the -s option is specified, lsof always displays the file
1753 size (or nothing if no size is available) and labels the
1754 column SIZE. The -o and -s options are mutually exclusive;
1755 they can't both be specified.
1756
1757 For files that don't have a fixed size - e.g., don't reside
1758 on a disk device - lsof will display appropriate information
1759 about the current size or position of the file if it is
1760 available in the kernel structures that define the file.
1761
1762 NLINK contains the file link count when +L has been specified;
1763
1764 NODE is the node number of a local file;
1765
1766 or the inode number of an NFS file in the server host;
1767
1768 or the Internet protocol type - e. g, ``TCP'';
1769
1770 or ``STR'' for a stream;
1771
1772 or ``CCITT'' for an HP-UX x.25 socket;
1773
1774 or the IRQ or inode number of a Linux AX.25 socket device.
1775
1776 NAME is the name of the mount point and file system on which the
1777 file resides;
1778
1779 or the name of a file specified in the names option (after
1780 any symbolic links have been resolved);
1781
1782 or the name of a character special or block special device;
1783
1784 or the local and remote Internet addresses of a network
1785 file; the local host name or IP number is followed by a
1786 colon (':'), the port, ``->'', and the two-part remote
1787 address; IP addresses may be reported as numbers or names,
1788 depending on the +|-M, -n, and -P options; colon-separated
1789 IPv6 numbers are enclosed in square brackets; IPv4
1790 INADDR_ANY and IPv6 IN6_IS_ADDR_UNSPECIFIED addresses, and
1791 zero port numbers are represented by an asterisk ('*'); a
1792 UDP destination address may be followed by the amount of
1793 time elapsed since the last packet was sent to the destina‐
1794 tion; TCP, UDP and UDPLITE remote addresses may be followed
1795 by TCP/TPI information in parentheses - state (e.g.,
1796 ``(ESTABLISHED)'', ``(Unbound)''), queue sizes, and window
1797 sizes (not all dialects) - in a fashion similar to what net‐
1798 stat(1) reports; see the -T option description or the
1799 description of the TCP/TPI field in OUTPUT FOR OTHER PRO‐
1800 GRAMS for more information on state, queue size, and window
1801 size;
1802
1803 or the address or name of a UNIX domain socket, possibly
1804 including a stream clone device name, a file system object's
1805 path name, local and foreign kernel addresses, socket pair
1806 information, and a bound vnode address;
1807
1808 or the local and remote mount point names of an NFS file;
1809
1810 or ``STR'', followed by the stream name;
1811
1812 or a stream character device name, followed by ``->'' and
1813 the stream name or a list of stream module names, separated
1814 by ``->'';
1815
1816 or ``STR:'' followed by the SCO OpenServer stream device and
1817 module names, separated by ``->'';
1818
1819 or system directory name, `` -- '', and as many components
1820 of the path name as lsof can find in the kernel's name cache
1821 for selected dialects (See the KERNEL NAME CACHE section for
1822 more information.);
1823
1824 or ``PIPE->'', followed by a Solaris kernel pipe destination
1825 address;
1826
1827 or ``COMMON:'', followed by the vnode device information
1828 structure's device name, for a Solaris common vnode;
1829
1830 or the address family, followed by a slash (`/'), followed
1831 by fourteen comma-separated bytes of a non-Internet raw
1832 socket address;
1833
1834 or the HP-UX x.25 local address, followed by the virtual
1835 connection number (if any), followed by the remote address
1836 (if any);
1837
1838 or ``(dead)'' for disassociated Tru64 UNIX files - typically
1839 terminal files that have been flagged with the TIOCNOTTY
1840 ioctl and closed by daemons;
1841
1842 or ``rd=<offset>'' and ``wr=<offset>'' for the values of the
1843 read and write offsets of a FIFO;
1844
1845 or ``clone n:/dev/event'' for SCO OpenServer file clones of
1846 the /dev/event device, where n is the minor device number of
1847 the file;
1848
1849 or ``(socketpair: n)'' for a Solaris 2.6, 8, 9 or 10 UNIX
1850 domain socket, created by the socketpair(3N) network func‐
1851 tion;
1852
1853 or ``no PCB'' for socket files that do not have a protocol
1854 block associated with them, optionally followed by ``,
1855 CANTSENDMORE'' if sending on the socket has been disabled,
1856 or ``, CANTRCVMORE'' if receiving on the socket has been
1857 disabled (e.g., by the shutdown(2) function);
1858
1859 or the local and remote addresses of a Linux IPX socket file
1860 in the form <net>:[<node>:]<port>, followed in parentheses
1861 by the transmit and receive queue sizes, and the connection
1862 state;
1863
1864 or ``dgram'' or ``stream'' for the type UnixWare 7.1.1 and
1865 above in-kernel UNIX domain sockets, followed by a colon
1866 (':') and the local path name when available, followed by
1867 ``->'' and the remote path name or kernel socket address in
1868 hexadecimal when available;
1869
1870 or the association value, association index, endpoint value,
1871 local address, local port, remote address and remote port
1872 for Linux SCTP sockets;
1873
1874 or ``protocol: '' followed by the Linux socket's protocol
1875 attribute.
1876
1877 For dialects that support a ``namefs'' file system, allowing one file
1878 to be attached to another with fattach(3C), lsof will add
1879 ``(FA:<address1><direction><address2>)'' to the NAME column.
1880 <address1> and <address2> are hexadecimal vnode addresses. <direction>
1881 will be ``<-'' if <address2> has been fattach'ed to this vnode whose
1882 address is <address1>; and ``->'' if <address1>, the vnode address of
1883 this vnode, has been fattach'ed to <address2>. <address1> may be omit‐
1884 ted if it already appears in the DEVICE column.
1885
1886 Lsof may add two parenthetical notes to the NAME column for open
1887 Solaris 10 files: ``(?)'' if lsof considers the path name of question‐
1888 able accuracy; and ``(deleted)'' if the -X option has been specified
1889 and lsof detects the open file's path name has been deleted. Consult
1890 the lsof FAQ (The FAQ section gives its location.) for more informa‐
1891 tion on these NAME column additions.
1892
1894 Lsof can't adequately report the wide variety of UNIX dialect file
1895 locks in a single character. What it reports in a single character is
1896 a compromise between the information it finds in the kernel and the
1897 limitations of the reporting format.
1898
1899 Moreover, when a process holds several byte level locks on a file, lsof
1900 only reports the status of the first lock it encounters. If it is a
1901 byte level lock, then the lock character will be reported in lower case
1902 - i.e., `r', `w', or `x' - rather than the upper case equivalent
1903 reported for a full file lock.
1904
1905 Generally lsof can only report on locks held by local processes on
1906 local files. When a local process sets a lock on a remotely mounted
1907 (e.g., NFS) file, the remote server host usually records the lock
1908 state. One exception is Solaris - at some patch levels of 2.3, and in
1909 all versions above 2.4, the Solaris kernel records information on
1910 remote locks in local structures.
1911
1912 Lsof has trouble reporting locks for some UNIX dialects. Consult the
1913 BUGS section of this manual page or the lsof FAQ (The FAQ section gives
1914 its location.) for more information.
1915
1917 When the -F option is specified, lsof produces output that is suitable
1918 for processing by another program - e.g, an awk or Perl script, or a C
1919 program.
1920
1921 Each unit of information is output in a field that is identified with a
1922 leading character and terminated by a NL (012) (or a NUL (000) if the 0
1923 (zero) field identifier character is specified.) The data of the field
1924 follows immediately after the field identification character and
1925 extends to the field terminator.
1926
1927 It is possible to think of field output as process and file sets. A
1928 process set begins with a field whose identifier is `p' (for process
1929 IDentifier (PID)). It extends to the beginning of the next PID field
1930 or the beginning of the first file set of the process, whichever comes
1931 first. Included in the process set are fields that identify the com‐
1932 mand, the process group IDentification (PGID) number, the task (thread)
1933 ID (TID), and the user ID (UID) number or login name.
1934
1935 A file set begins with a field whose identifier is `f' (for file
1936 descriptor). It is followed by lines that describe the file's access
1937 mode, lock state, type, device, size, offset, inode, protocol, name and
1938 stream module names. It extends to the beginning of the next file or
1939 process set, whichever comes first.
1940
1941 When the NUL (000) field terminator has been selected with the 0 (zero)
1942 field identifier character, lsof ends each process and file set with a
1943 NL (012) character.
1944
1945 Lsof always produces one field, the PID (`p') field. All other fields
1946 may be declared optionally in the field identifier character list that
1947 follows the -F option. When a field selection character identifies an
1948 item lsof does not normally list - e.g., PPID, selected with -R - spec‐
1949 ification of the field character - e.g., ``-FR'' - also selects the
1950 listing of the item.
1951
1952 It is entirely possible to select a set of fields that cannot easily be
1953 parsed - e.g., if the field descriptor field is not selected, it may be
1954 difficult to identify file sets. To help you avoid this difficulty,
1955 lsof supports the -F option; it selects the output of all fields with
1956 NL terminators (the -F0 option pair selects the output of all fields
1957 with NUL terminators). For compatibility reasons neither -F nor -F0
1958 select the raw device field.
1959
1960 These are the fields that lsof will produce. The single character
1961 listed first is the field identifier.
1962
1963 a file access mode
1964 c process command name (all characters from proc or
1965 user structure)
1966 C file structure share count
1967 d file's device character code
1968 D file's major/minor device number (0x<hexadecimal>)
1969 f file descriptor
1970 F file structure address (0x<hexadecimal>)
1971 G file flaGs (0x<hexadecimal>; names if +fg follows)
1972 g process group ID
1973 i file's inode number
1974 K tasK ID
1975 k link count
1976 l file's lock status
1977 L process login name
1978 m marker between repeated output
1979 n file name, comment, Internet address
1980 N node identifier (ox<hexadecimal>
1981 o file's offset (decimal)
1982 p process ID (always selected)
1983 P protocol name
1984 r raw device number (0x<hexadecimal>)
1985 R parent process ID
1986 s file's size (decimal)
1987 S file's stream identification
1988 t file's type
1989 T TCP/TPI information, identified by prefixes (the
1990 `=' is part of the prefix):
1991 QR=<read queue size>
1992 QS=<send queue size>
1993 SO=<socket options and values> (not all dialects)
1994 SS=<socket states> (not all dialects)
1995 ST=<connection state>
1996 TF=<TCP flags and values> (not all dialects)
1997 WR=<window read size> (not all dialects)
1998 WW=<window write size> (not all dialects)
1999 (TCP/TPI information isn't reported for all supported
2000 UNIX dialects. The -h or -? help output for the
2001 -T option will show what TCP/TPI reporting can be
2002 requested.)
2003 u process user ID
2004 z Solaris 10 and higher zone name
2005 Z SELinux security context (inhibited when SELinux is disabled)
2006 0 use NUL field terminator character in place of NL
2007 1-9 dialect-specific field identifiers (The output
2008 of -F? identifies the information to be found
2009 in dialect-specific fields.)
2010
2011 You can get on-line help information on these characters and their
2012 descriptions by specifying the -F? option pair. (Escape the `?' char‐
2013 acter as your shell requires.) Additional information on field content
2014 can be found in the OUTPUT section.
2015
2016 As an example, ``-F pcfn'' will select the process ID (`p'), command
2017 name (`c'), file descriptor (`f') and file name (`n') fields with an NL
2018 field terminator character; ``-F pcfn0'' selects the same output with a
2019 NUL (000) field terminator character.
2020
2021 Lsof doesn't produce all fields for every process or file set, only
2022 those that are available. Some fields are mutually exclusive: file
2023 device characters and file major/minor device numbers; file inode num‐
2024 ber and protocol name; file name and stream identification; file size
2025 and offset. One or the other member of these mutually exclusive sets
2026 will appear in field output, but not both.
2027
2028 Normally lsof ends each field with a NL (012) character. The 0 (zero)
2029 field identifier character may be specified to change the field termi‐
2030 nator character to a NUL (000). A NUL terminator may be easier to
2031 process with xargs [4m(1), for example, or with programs whose quoting
2032 mechanisms may not easily cope with the range of characters in the
2033 field output. When the NUL field terminator is in use, lsof ends each
2034 process and file set with a NL (012).
2035
2036 Three aids to producing programs that can process lsof field output are
2037 included in the lsof distribution. The first is a C header file,
2038 lsof_fields.h, that contains symbols for the field identification char‐
2039 acters, indexes for storing them in a table, and explanation strings
2040 that may be compiled into programs. Lsof uses this header file.
2041
2042 The second aid is a set of sample scripts that process field output,
2043 written in awk, Perl 4, and Perl 5. They're located in the scripts
2044 subdirectory of the lsof distribution.
2045
2046 The third aid is the C library used for the lsof test suite. The test
2047 suite is written in C and uses field output to validate the correct
2048 operation of lsof. The library can be found in the tests/LTlib.c file
2049 of the lsof distribution. The library uses the first aid, the
2050 lsof_fields.h header file.
2051
2053 Lsof can be blocked by some kernel functions that it uses - lstat(2),
2054 readlink(2), and stat(2). These functions are stalled in the kernel,
2055 for example, when the hosts where mounted NFS file systems reside
2056 become inaccessible.
2057
2058 Lsof attempts to break these blocks with timers and child processes,
2059 but the techniques are not wholly reliable. When lsof does manage to
2060 break a block, it will report the break with an error message. The
2061 messages may be suppressed with the -t and -w options.
2062
2063 The default timeout value may be displayed with the -h or -? option,
2064 and it may be changed with the -S [t] option. The minimum for t is two
2065 seconds, but you should avoid small values, since slow system respon‐
2066 siveness can cause short timeouts to expire unexpectedly and perhaps
2067 stop lsof before it can produce any output.
2068
2069 When lsof has to break a block during its access of mounted file system
2070 information, it normally continues, although with less information
2071 available to display about open files.
2072
2073 Lsof can also be directed to avoid the protection of timers and child
2074 processes when using the kernel functions that might block by specify‐
2075 ing the -O option. While this will allow lsof to start up with less
2076 overhead, it exposes lsof completely to the kernel situations that
2077 might block it. Use this option cautiously.
2078
2080 You can use the -b option to tell lsof to avoid using kernel functions
2081 that would block. Some cautions apply.
2082
2083 First, using this option usually requires that your system supply
2084 alternate device numbers in place of the device numbers that lsof would
2085 normally obtain with the lstat(2) and stat(2) kernel functions. See
2086 the ALTERNATE DEVICE NUMBERS section for more information on alternate
2087 device numbers.
2088
2089 Second, you can't specify names for lsof to locate unless they're file
2090 system names. This is because lsof needs to know the device and inode
2091 numbers of files listed with names in the lsof options, and the -b
2092 option prevents lsof from obtaining them. Moreover, since lsof only
2093 has device numbers for the file systems that have alternates, its abil‐
2094 ity to locate files on file systems depends completely on the avail‐
2095 ability and accuracy of the alternates. If no alternates are avail‐
2096 able, or if they're incorrect, lsof won't be able to locate files on
2097 the named file systems.
2098
2099 Third, if the names of your file system directories that lsof obtains
2100 from your system's mount table are symbolic links, lsof won't be able
2101 to resolve the links. This is because the -b option causes lsof to
2102 avoid the kernel readlink(2) function it uses to resolve symbolic
2103 links.
2104
2105 Finally, using the -b option causes lsof to issue warning messages when
2106 it needs to use the kernel functions that the -b option directs it to
2107 avoid. You can suppress these messages by specifying the -w option,
2108 but if you do, you won't see the alternate device numbers reported in
2109 the warning messages.
2110
2112 On some dialects, when lsof has to break a block because it can't get
2113 information about a mounted file system via the lstat(2) and stat(2)
2114 kernel functions, or because you specified the -b option, lsof can
2115 obtain some of the information it needs - the device number and possi‐
2116 bly the file system type - from the system mount table. When that is
2117 possible, lsof will report the device number it obtained. (You can
2118 suppress the report by specifying the -w option.)
2119
2120 You can assist this process if your mount table is supported with an
2121 /etc/mtab or /etc/mnttab file that contains an options field by adding
2122 a ``dev=xxxx'' field for mount points that do not have one in their
2123 options strings. Note: you must be able to edit the file - i.e., some
2124 mount tables like recent Solaris /etc/mnttab or Linux /proc/mounts are
2125 read-only and can't be modified.
2126
2127 You may also be able to supply device numbers using the +m and +m m
2128 options, provided they are supported by your dialect. Check the output
2129 of lsof's -h or -? options to see if the +m and +m m options are
2130 available.
2131
2132 The ``xxxx'' portion of the field is the hexadecimal value of the file
2133 system's device number. (Consult the st_dev field of the output of the
2134 lstat(2) and stat(2) functions for the appropriate values for your file
2135 systems.) Here's an example from a Sun Solaris 2.6 /etc/mnttab for a
2136 file system remotely mounted via NFS:
2137
2138 nfs ignore,noquota,dev=2a40001
2139
2140 There's an advantage to having ``dev=xxxx'' entries in your mount table
2141 file, especially for file systems that are mounted from remote NFS
2142 servers. When a remote server crashes and you want to identify its
2143 users by running lsof on one of its clients, lsof probably won't be
2144 able to get output from the lstat(2) and stat(2) functions for the file
2145 system. If it can obtain the file system's device number from the
2146 mount table, it will be able to display the files open on the crashed
2147 NFS server.
2148
2149 Some dialects that do not use an ASCII /etc/mtab or /etc/mnttab file
2150 for the mount table may still provide an alternative device number in
2151 their internal mount tables. This includes AIX, Apple Darwin, FreeBSD,
2152 NetBSD, OpenBSD, and Tru64 UNIX. Lsof knows how to obtain the alterna‐
2153 tive device number for these dialects and uses it when its attempt to
2154 lstat(2) or stat(2) the file system is blocked.
2155
2156 If you're not sure your dialect supplies alternate device numbers for
2157 file systems from its mount table, use this lsof incantation to see if
2158 it reports any alternate device numbers:
2159
2160 lsof -b
2161
2162 Look for standard error file warning messages that begin ``assuming
2163 "dev=xxxx" from ...''.
2164
2166 Lsof is able to examine the kernel's name cache or use other kernel
2167 facilities (e.g., the ADVFS 4.x tag_to_path() function under Tru64
2168 UNIX) on some dialects for most file system types, excluding AFS, and
2169 extract recently used path name components from it. (AFS file system
2170 path lookups don't use the kernel's name cache; some Solaris VxFS file
2171 system operations apparently don't use it, either.)
2172
2173 Lsof reports the complete paths it finds in the NAME column. If lsof
2174 can't report all components in a path, it reports in the NAME column
2175 the file system name, followed by a space, two `-' characters, another
2176 space, and the name components it has located, separated by the `/'
2177 character.
2178
2179 When lsof is run in repeat mode - i.e., with the -r option specified -
2180 the extent to which it can report path name components for the same
2181 file may vary from cycle to cycle. That's because other running pro‐
2182 cesses can cause the kernel to remove entries from its name cache and
2183 replace them with others.
2184
2185 Lsof's use of the kernel name cache to identify the paths of files can
2186 lead it to report incorrect components under some circumstances. This
2187 can happen when the kernel name cache uses device and node number as a
2188 key (e.g., SCO OpenServer) and a key on a rapidly changing file system
2189 is reused. If the UNIX dialect's kernel doesn't purge the name cache
2190 entry for a file when it is unlinked, lsof may find a reference to the
2191 wrong entry in the cache. The lsof FAQ (The FAQ section gives its
2192 location.) has more information on this situation.
2193
2194 Lsof can report path name components for these dialects:
2195
2196 FreeBSD
2197 HP-UX
2198 Linux
2199 NetBSD
2200 NEXTSTEP
2201 OpenBSD
2202 OPENSTEP
2203 SCO OpenServer
2204 SCO|Caldera UnixWare
2205 Solaris
2206 Tru64 UNIX
2207
2208 Lsof can't report path name components for these dialects:
2209
2210 AIX
2211
2212 If you want to know why lsof can't report path name components for some
2213 dialects, see the lsof FAQ (The FAQ section gives its location.)
2214
2216 Examining all members of the /dev (or /devices) node tree with stat(2)
2217 functions can be time consuming. What's more, the information that
2218 lsof needs - device number, inode number, and path - rarely changes.
2219
2220 Consequently, lsof normally maintains an ASCII text file of cached /dev
2221 (or /devices) information (exception: the /proc-based Linux lsof where
2222 it's not needed.) The local system administrator who builds lsof can
2223 control the way the device cache file path is formed, selecting from
2224 these options:
2225
2226 Path from the -D option;
2227 Path from an environment variable;
2228 System-wide path;
2229 Personal path (the default);
2230 Personal path, modified by an environment variable.
2231
2232 Consult the output of the -h, -D? , or -? help options for the current
2233 state of device cache support. The help output lists the default
2234 read-mode device cache file path that is in effect for the current
2235 invocation of lsof. The -D? option output lists the read-only and
2236 write device cache file paths, the names of any applicable environment
2237 variables, and the personal device cache path format.
2238
2239 Lsof can detect that the current device cache file has been acciden‐
2240 tally or maliciously modified by integrity checks, including the compu‐
2241 tation and verification of a sixteen bit Cyclic Redundancy Check (CRC)
2242 sum on the file's contents. When lsof senses something wrong with the
2243 file, it issues a warning and attempts to remove the current cache file
2244 and create a new copy, but only to a path that the process can legiti‐
2245 mately write.
2246
2247 The path from which a lsof process may attempt to read a device cache
2248 file may not be the same as the path to which it can legitimately
2249 write. Thus when lsof senses that it needs to update the device cache
2250 file, it may choose a different path for writing it from the path from
2251 which it read an incorrect or outdated version.
2252
2253 If available, the -Dr option will inhibit the writing of a new device
2254 cache file. (It's always available when specified without a path name
2255 argument.)
2256
2257 When a new device is added to the system, the device cache file may
2258 need to be recreated. Since lsof compares the mtime of the device
2259 cache file with the mtime and ctime of the /dev (or /devices) direc‐
2260 tory, it usually detects that a new device has been added; in that case
2261 lsof issues a warning message and attempts to rebuild the device cache
2262 file.
2263
2264 Whenever lsof writes a device cache file, it sets its ownership to the
2265 real UID of the executing process, and its permission modes to 0600,
2266 this restricting its reading and writing to the file's owner.
2267
2269 Two permissions of the lsof executable affect its ability to access
2270 device cache files. The permissions are set by the local system admin‐
2271 istrator when lsof is installed.
2272
2273 The first and rarer permission is setuid-root. It comes into effect
2274 when lsof is executed; its effective UID is then root, while its real
2275 (i.e., that of the logged-on user) UID is not. The lsof distribution
2276 recommends that versions for these dialects run setuid-root.
2277
2278 HP-UX 11.11 and 11.23
2279 Linux
2280
2281 The second and more common permission is setgid. It comes into effect
2282 when the effective group IDentification number (GID) of the lsof
2283 process is set to one that can access kernel memory devices - e.g.,
2284 ``kmem'', ``sys'', or ``system''.
2285
2286 An lsof process that has setgid permission usually surrenders the per‐
2287 mission after it has accessed the kernel memory devices. When it does
2288 that, lsof can allow more liberal device cache path formations. The
2289 lsof distribution recommends that versions for these dialects run set‐
2290 gid and be allowed to surrender setgid permission.
2291
2292 AIX 5.[12] and 5.3-ML1
2293 Apple Darwin 7.x Power Macintosh systems
2294 FreeBSD 4.x, 4.1x, 5.x and [6789].x for x86-based systems
2295 FreeBSD 5.x and [6789].x for Alpha, AMD64 and Sparc64-based
2296 systems
2297 HP-UX 11.00
2298 NetBSD 1.[456], 2.x and 3.x for Alpha, x86, and SPARC-based
2299 systems
2300 NEXTSTEP 3.[13] for NEXTSTEP architectures
2301 OpenBSD 2.[89] and 3.[0-9] for x86-based systems
2302 OPENSTEP 4.x
2303 SCO OpenServer Release 5.0.6 for x86-based systems
2304 SCO|Caldera UnixWare 7.1.4 for x86-based systems
2305 Solaris 2.6, 8, 9 and 10
2306 Tru64 UNIX 5.1
2307
2308 (Note: lsof for AIX 5L and above needs setuid-root permission if its -X
2309 option is used.)
2310
2311 Lsof for these dialects does not support a device cache, so the permis‐
2312 sions given to the executable don't apply to the device cache file.
2313
2314 Linux
2315
2317 The -D option provides limited means for specifying the device cache
2318 file path. Its ? function will report the read-only and write device
2319 cache file paths that lsof will use.
2320
2321 When the -D b, r, and u functions are available, you can use them to
2322 request that the cache file be built in a specific location (b[path]);
2323 read but not rebuilt (r[path]); or read and rebuilt (u[path]). The b,
2324 r, and u functions are restricted under some conditions. They are
2325 restricted when the lsof process is setuid-root. The path specified
2326 with the r function is always read-only, even when it is available.
2327
2328 The b, r, and u functions are also restricted when the lsof process
2329 runs setgid and lsof doesn't surrender the setgid permission. (See the
2330 LSOF PERMISSIONS THAT AFFECT DEVICE CACHE FILE ACCESS section for a
2331 list of implementations that normally don't surrender their setgid per‐
2332 mission.)
2333
2334 A further -D function, i (for ignore), is always available.
2335
2336 When available, the b function tells lsof to read device information
2337 from the kernel with the stat(2) function and build a device cache file
2338 at the indicated path.
2339
2340 When available, the r function tells lsof to read the device cache
2341 file, but not update it. When a path argument accompanies -Dr, it
2342 names the device cache file path. The r function is always available
2343 when it is specified without a path name argument. If lsof is not run‐
2344 ning setuid-root and surrenders its setgid permission, a path name
2345 argument may accompany the r function.
2346
2347 When available, the u function tells lsof to attempt to read and use
2348 the device cache file. If it can't read the file, or if it finds the
2349 contents of the file incorrect or outdated, it will read information
2350 from the kernel, and attempt to write an updated version of the device
2351 cache file, but only to a path it considers legitimate for the lsof
2352 process effective and real UIDs.
2353
2355 Lsof's second choice for the device cache file is the contents of the
2356 LSOFDEVCACHE environment variable. It avoids this choice if the lsof
2357 process is setuid-root, or the real UID of the process is root.
2358
2359 A further restriction applies to a device cache file path taken from
2360 the LSOFDEVCACHE environment variable: lsof will not write a device
2361 cache file to the path if the lsof process doesn't surrender its setgid
2362 permission. (See the LSOF PERMISSIONS THAT AFFECT DEVICE CACHE FILE
2363 ACCESS section for information on implementations that don't surrender
2364 their setgid permission.)
2365
2366 The local system administrator can disable the use of the LSOFDEVCACHE
2367 environment variable or change its name when building lsof. Consult
2368 the output of -D? for the environment variable's name.
2369
2371 The local system administrator may choose to have a system-wide device
2372 cache file when building lsof. That file will generally be constructed
2373 by a special system administration procedure when the system is booted
2374 or when the contents of /dev or /devices) changes. If defined, it is
2375 lsof's third device cache file path choice.
2376
2377 You can tell that a system-wide device cache file is in effect for your
2378 local installation by examining the lsof help option output - i.e., the
2379 output from the -h or -? option.
2380
2381 Lsof will never write to the system-wide device cache file path by
2382 default. It must be explicitly named with a -D function in a
2383 root-owned procedure. Once the file has been written, the procedure
2384 must change its permission modes to 0644 (owner-read and owner-write,
2385 group-read, and other-read).
2386
2388 The default device cache file path of the lsof distribution is one
2389 recorded in the home directory of the real UID that executes lsof.
2390 Added to the home directory is a second path component of the form
2391 .lsof_hostname.
2392
2393 This is lsof's fourth device cache file path choice, and is usually the
2394 default. If a system-wide device cache file path was defined when lsof
2395 was built, this fourth choice will be applied when lsof can't find the
2396 system-wide device cache file. This is the only time lsof uses two
2397 paths when reading the device cache file.
2398
2399 The hostname part of the second component is the base name of the exe‐
2400 cuting host, as returned by gethostname(2). The base name is defined
2401 to be the characters preceding the first `.' in the gethostname(2)
2402 output, or all the gethostname(2) output if it contains no `.'.
2403
2404 The device cache file belongs to the user ID and is readable and
2405 writable by the user ID alone - i.e., its modes are 0600. Each dis‐
2406 tinct real user ID on a given host that executes lsof has a distinct
2407 device cache file. The hostname part of the path distinguishes device
2408 cache files in an NFS-mounted home directory into which device cache
2409 files are written from several different hosts.
2410
2411 The personal device cache file path formed by this method represents a
2412 device cache file that lsof will attempt to read, and will attempt to
2413 write should it not exist or should its contents be incorrect or out‐
2414 dated.
2415
2416 The -Dr option without a path name argument will inhibit the writing of
2417 a new device cache file.
2418
2419 The -D? option will list the format specification for constructing the
2420 personal device cache file. The conversions used in the format speci‐
2421 fication are described in the 00DCACHE file of the lsof distribution.
2422
2424 If this option is defined by the local system administrator when lsof
2425 is built, the LSOFPERSDCPATH environment variable contents may be used
2426 to add a component of the personal device cache file path.
2427
2428 The LSOFPERSDCPATH variable contents are inserted in the path at the
2429 place marked by the local system administrator with the ``%p'' conver‐
2430 sion in the HASPERSDC format specification of the dialect's machine.h
2431 header file. (It's placed right after the home directory in the
2432 default lsof distribution.)
2433
2434 Thus, for example, if LSOFPERSDCPATH contains ``LSOF'', the home direc‐
2435 tory is ``/Homes/abe'', the host name is ``lsof.itap.purdue.edu'', and
2436 the HASPERSDC format is the default (``%h/%p.lsof_%L''), the modified
2437 personal device cache file path is:
2438
2439 /Homes/abe/LSOF/.lsof_vic
2440
2441 The LSOFPERSDCPATH environment variable is ignored when the lsof
2442 process is setuid-root or when the real UID of the process is root.
2443
2444 Lsof will not write to a modified personal device cache file path if
2445 the lsof process doesn't surrender setgid permission. (See the LSOF
2446 PERMISSIONS THAT AFFECT DEVICE CACHE FILE ACCESS section for a list of
2447 implementations that normally don't surrender their setgid permission.)
2448
2449 If, for example, you want to create a sub-directory of personal device
2450 cache file paths by using the LSOFPERSDCPATH environment variable to
2451 name it, and lsof doesn't surrender its setgid permission, you will
2452 have to allow lsof to create device cache files at the standard per‐
2453 sonal path and move them to your subdirectory with shell commands.
2454
2455 The local system administrator may: disable this option when lsof is
2456 built; change the name of the environment variable from LSOFPERSDCPATH
2457 to something else; change the HASPERSDC format to include the personal
2458 path component in another place; or exclude the personal path component
2459 entirely. Consult the output of the -D? option for the environment
2460 variable's name and the HASPERSDC format specification.
2461
2463 Errors are identified with messages on the standard error file.
2464
2465 Lsof returns a one (1) if any error was detected, including the failure
2466 to locate command names, file names, Internet addresses or files, login
2467 names, NFS files, PIDs, PGIDs, or UIDs it was asked to list. If the -V
2468 option is specified, lsof will indicate the search items it failed to
2469 list.
2470
2471 It returns a zero (0) if no errors were detected and if it was able to
2472 list some information about all the specified search arguments.
2473
2474 When lsof cannot open access to /dev (or /devices) or one of its subdi‐
2475 rectories, or get information on a file in them with stat(2), it issues
2476 a warning message and continues. That lsof will issue warning messages
2477 about inaccessible files in /dev (or /devices) is indicated in its help
2478 output - requested with the -h or >B -? options - with the message:
2479
2480 Inaccessible /dev warnings are enabled.
2481
2482 The warning message may be suppressed with the -w option. It may also
2483 have been suppressed by the system administrator when lsof was compiled
2484 by the setting of the WARNDEVACCESS definition. In this case, the out‐
2485 put from the help options will include the message:
2486
2487 Inaccessible /dev warnings are disabled.
2488
2489 Inaccessible device warning messages usually disappear after lsof has
2490 created a working device cache file.
2491
2493 For a more extensive set of examples, documented more fully, see the
2494 00QUICKSTART file of the lsof distribution.
2495
2496 To list all open files, use:
2497
2498 lsof
2499
2500 To list all open Internet, x.25 (HP-UX), and UNIX domain files, use:
2501
2502 lsof -i -U
2503
2504 To list all open IPv4 network files in use by the process whose PID is
2505 1234, use:
2506
2507 lsof -i 4 -a -p 1234
2508
2509 Presuming the UNIX dialect supports IPv6, to list only open IPv6 net‐
2510 work files, use:
2511
2512 lsof -i 6
2513
2514 To list all files using any protocol on ports 513, 514, or 515 of host
2515 wonderland.cc.purdue.edu, use:
2516
2517 lsof -i @wonderland.cc.purdue.edu:513-515
2518
2519 To list all files using any protocol on any port of mace.cc.purdue.edu
2520 (cc.purdue.edu is the default domain), use:
2521
2522 lsof -i @mace
2523
2524 To list all open files for login name ``abe'', or user ID 1234, or
2525 process 456, or process 123, or process 789, use:
2526
2527 lsof -p 456,123,789 -u 1234,abe
2528
2529 To list all open files on device /dev/hd4, use:
2530
2531 lsof /dev/hd4
2532
2533 To find the process that has /u/abe/foo open, use:
2534
2535 lsof /u/abe/foo
2536
2537 To send a SIGHUP to the processes that have /u/abe/bar open, use:
2538
2539 kill -HUP `lsof -t /u/abe/bar`
2540
2541 To find any open file, including an open UNIX domain socket file, with
2542 the name /dev/log, use:
2543
2544 lsof /dev/log
2545
2546 To find processes with open files on the NFS file system named
2547 /nfs/mount/point whose server is inaccessible, and presuming your mount
2548 table supplies the device number for /nfs/mount/point, use:
2549
2550 lsof -b /nfs/mount/point
2551
2552 To do the preceding search with warning messages suppressed, use:
2553
2554 lsof -bw /nfs/mount/point
2555
2556 To ignore the device cache file, use:
2557
2558 lsof -Di
2559
2560 To obtain PID and command name field output for each process, file
2561 descriptor, file device number, and file inode number for each file of
2562 each process, use:
2563
2564 lsof -FpcfDi
2565
2566 To list the files at descriptors 1 and 3 of every process running the
2567 lsof command for login ID ``abe'' every 10 seconds, use:
2568
2569 lsof -c lsof -a -d 1 -d 3 -u abe -r10
2570
2571 To list the current working directory of processes running a command
2572 that is exactly four characters long and has an 'o' or 'O' in character
2573 three, use this regular expression form of the -c c option:
2574
2575 lsof -c /^..o.$/i -a -d cwd
2576
2577 To find an IP version 4 socket file by its associated numeric dot-form
2578 address, use:
2579
2580 lsof -i@128.210.15.17
2581
2582 To find an IP version 6 socket file (when the UNIX dialect supports
2583 IPv6) by its associated numeric colon-form address, use:
2584
2585 lsof -i@[0:1:2:3:4:5:6:7]
2586
2587 To find an IP version 6 socket file (when the UNIX dialect supports
2588 IPv6) by an associated numeric colon-form address that has a run of
2589 zeroes in it - e.g., the loop-back address - use:
2590
2591 lsof -i@[::1]
2592
2593 To obtain a repeat mode marker line that contains the current time,
2594 use:
2595
2596 lsof -rm====%T====
2597
2598 To add spaces to the previous marker line, use:
2599
2600 lsof -r "m==== %T ===="
2601
2603 Since lsof reads kernel memory in its search for open files, rapid
2604 changes in kernel memory may produce unpredictable results.
2605
2606 When a file has multiple record locks, the lock status character (fol‐
2607 lowing the file descriptor) is derived from a test of the first lock
2608 structure, not from any combination of the individual record locks that
2609 might be described by multiple lock structures.
2610
2611 Lsof can't search for files with restrictive access permissions by name
2612 unless it is installed with root set-UID permission. Otherwise it is
2613 limited to searching for files to which its user or its set-GID group
2614 (if any) has access permission.
2615
2616 The display of the destination address of a raw socket (e.g., for ping)
2617 depends on the UNIX operating system. Some dialects store the destina‐
2618 tion address in the raw socket's protocol control block, some do not.
2619
2620 Lsof can't always represent Solaris device numbers in the same way that
2621 ls(1) does. For example, the major and minor device numbers that the
2622 lstat(2) and stat(2) functions report for the directory on which CD-ROM
2623 files are mounted (typically /cdrom) are not the same as the ones that
2624 it reports for the device on which CD-ROM files are mounted (typically
2625 /dev/sr0). (Lsof reports the directory numbers.)
2626
2627 The support for /proc file systems is available only for BSD and Tru64
2628 UNIX dialects, Linux, and dialects derived from SYSV R4 - e.g., Free‐
2629 BSD, NetBSD, OpenBSD, Solaris, UnixWare.
2630
2631 Some /proc file items - device number, inode number, and file size -
2632 are unavailable in some dialects. Searching for files in a /proc file
2633 system may require that the full path name be specified.
2634
2635 No text (txt) file descriptors are displayed for Linux processes. All
2636 entries for files other than the current working directory, the root
2637 directory, and numerical file descriptors are labeled mem descriptors.
2638
2639 Lsof can't search for Tru64 UNIX named pipes by name, because their
2640 kernel implementation of lstat(2) returns an improper device number for
2641 a named pipe.
2642
2643 Lsof can't report fully or correctly on HP-UX 9.01, 10.20, and 11.00
2644 locks because of insufficient access to kernel data or errors in the
2645 kernel data. See the lsof FAQ (The FAQ section gives its location.)
2646 for details.
2647
2648 The AIX SMT file type is a fabrication. It's made up for file struc‐
2649 tures whose type (15) isn't defined in the AIX /usr/include/sys/file.h
2650 header file. One way to create such file structures is to run X
2651 clients with the DISPLAY variable set to ``:0.0''.
2652
2653 The +|-f[cfgGn] option is not supported under /proc-based Linux lsof,
2654 because it doesn't read kernel structures from kernel memory.
2655
2657 Lsof may access these environment variables.
2658
2659 LANG defines a language locale. See setlocale(3) for the
2660 names of other variables that can be used in place of
2661 LANG - e.g., LC_ALL, LC_TYPE, etc.
2662
2663 LSOFDEVCACHE defines the path to a device cache file. See the
2664 DEVICE CACHE PATH FROM AN ENVIRONMENT VARIABLE sec‐
2665 tion for more information.
2666
2667 LSOFPERSDCPATH defines the middle component of a modified personal
2668 device cache file path. See the MODIFIED PERSONAL
2669 DEVICE CACHE PATH section for more information.
2670
2672 Frequently-asked questions and their answers (an FAQ) are available in
2673 the 00FAQ file of the lsof distribution.
2674
2675 That file is also available via anonymous ftp from lsof.itap.purdue.edu
2676 at pub/tools/unix/lsofFAQ. The URL is:
2677
2678 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/FAQ
2679
2681 /dev/kmem kernel virtual memory device
2682
2683 /dev/mem physical memory device
2684
2685 /dev/swap system paging device
2686
2687 .lsof_hostname lsof's device cache file (The suffix, hostname, is
2688 the first component of the host's name returned by
2689 gethostname(2).)
2690
2692 Lsof was written by Victor A. Abell <abe@purdue.edu> of Purdue Univer‐
2693 sity. Many others have contributed to lsof. They're listed in the
2694 00CREDITS file of the lsof distribution.
2695
2697 The latest distribution of lsof is available via anonymous ftp from the
2698 host lsof.itap.purdue.edu. You'll find the lsof distribution in the
2699 pub/tools/unix/lsof directory.
2700
2701 You can also use this URL:
2702
2703 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof
2704
2705 Lsof is also mirrored elsewhere. When you access lsof.itap.purdue.edu
2706 and change to its pub/tools/unix/lsof directory, you'll be given a list
2707 of some mirror sites. The pub/tools/unix/lsof directory also contains
2708 a more complete list in its mirrors file. Use mirrors with caution -
2709 not all mirrors always have the latest lsof revision.
2710
2711 Some pre-compiled Lsof executables are available on lsof.itap.pur‐
2712 due.edu, but their use is discouraged - it's better that you build your
2713 own from the sources. If you feel you must use a pre-compiled exe‐
2714 cutable, please read the cautions that appear in the README files of
2715 the pub/tools/unix/lsof/binaries subdirectories and in the 00* files of
2716 the distribution.
2717
2718 More information on the lsof distribution can be found in its
2719 README.lsof_<version> file. If you intend to get the lsof distribution
2720 and build it, please read README.lsof_<version> and the other 00* files
2721 of the distribution before sending questions to the author.
2722
2724 Not all the following manual pages may exist in every UNIX dialect to
2725 which lsof has been ported.
2726
2727 access(2), awk(1), crash(1), fattach(3C), ff(1), fstat(8), fuser(1),
2728 gethostname(2), isprint(3), kill(1), localtime(3), lstat(2), mod‐
2729 load(8), mount(8), netstat(1), ofiles(8L), perl(1), ps(1), readlink(2),
2730 setlocale(3), stat(2), strftime(3), time(2), uname(1).
2731
2732
2733
2734 Revision-4.87 LSOF(8)