Penguin
Annotated edit history of lsof(8) version 3, including all changes. View license author blame.
Rev Author # Line
1 perry 1 !!NAME
3 CraigBox 2 lsof - list open files
1 perry 3
4 !!SYNOPSIS
3 CraigBox 5 __lsof__ [[ __-?abChlnNOPRstUvVX__ ] [[ __-A__ '' A'' ] [[ __-c__ '' c'' ] [[ __+|-d__ '' d'' ] [[ __+|-D__ '' D'' ] [[ __+|-f [[cfgGn]__ ] [[ __-F__ '' [[f]'' ] [[ __-g__ '' [[s]'' ] [[ __-i__ '' [[i]'' ] [[ __-k__ '' k'' ] [[ __+|-L__ '' [[l]'' ] [[ __-m__ '' m'' ] [[ __+|-M__ ] [[ __-o__ '' [[o]'' ] [[ __-p__ '' s'' ] [[ __+|-r__ '' [[t]'' ] [[ __-S__ '' [[t]'' ] [[ __-T__ '' [[t]'' ] [[ __-u__ '' s'' ] [[ __+|-w__ ] [[ __--__ ] [[''names'']
1 perry 6
7 !!DESCRIPTION
3 CraigBox 8 ''Lsof'' revision 4.57 lists information about files opened by processes for the following UNIX dialects:
1 perry 9
3 CraigBox 10 * AIX 4.3.[[23], 5L, and 5.1 %%%
11 * Apple Darwin 1.[[23] for Power Macintosh systems %%%
12 * BSDI BSD/OS 4.1 for Intel-based systems %%%
13 * DEC OSF/1, Digital UNIX, Tru64 UNIX 4.0, and 5.[[01] %%%
14 * FreeBSD 4.[[23] and 5.0 for Intel-based systems %%%
15 * HP-UX 11.00 and 11.11 %%%
16 * Linux 2.1.72 and above for Intel-based systems %%%
17 * NetBSD 1.5 for Alpha, Intel, and SPARC-based systems %%%
18 * NEXTSTEP 3.[[13] for NEXTSTEP architectures %%%
19 * OpenBSD 2.[[89] for Intel-based systems %%%
20 * !OpenStep 4.x %%%
21 * SCO !OpenServer Release 5.0.[[45] for Intel-based systems %%%
22 * SCO !UnixWare 7.1.1 for Intel-based systems %%%
23 * Sequent PTX 4.4[[.46], 4.5[[.1], and 4.6[[.1] for Sequent systems %%%
24 * Solaris 2.6, 7, 8, and 9 BETA %%%
1 perry 25
26
27 (See the __DISTRIBUTION__ section of this manual page for information on how to obtain the latest ''lsof'' revision.)
28
3 CraigBox 29 An open file may be a regular file, a directory, a block special file, a character special file, an executing text reference, a library, a stream or a network file (Internet socket, NFS file or UNIX domain socket.) A specific file or all the files in a file system may be selected by path.
1 perry 30
3 CraigBox 31 Instead of a formatted display, ''lsof'' will produce output that can be parsed by other programs. See the __-F__ , option description, and the __OUTPUT FOR OTHER PROGRAMS__ section for more information.
1 perry 32
3 CraigBox 33 In addition to producing a single output list, ''lsof'' will run in repeat mode. In repeat mode it will produce output, delay, then repeat the output operation until stopped with an interrupt or quit signal. See the __+|-r__ '' [[t]'' option description for more information.
1 perry 34
35 !!OPTIONS
3 CraigBox 36 In the absence of any options, ''lsof'' lists all open files belonging to all active processes.
1 perry 37
3 CraigBox 38 If any list request option is specified, other list requests must be specifically requested - e.g., if __-U__ is specified for the listing of UNIX socket files, NFS files won't be listed unless __-N__ is also specified; or if a user list is specified with the __-u__ option, UNIX domain socket files, belonging to users not in the list, won't be listed unless the __-U__ option is also specified.
1 perry 39
3 CraigBox 40 Normally list options that are specifically stated are ORed - i.e., specifying the __-i__ option without an address and the __-u__foo option produces a listing of all network files OR files belonging to processes owned by user "foo". One exception is the `^' (negated) login name or user ID (UID) specified with the __-u__ option. Since it is an exclusion, it is applied without ORing or ANDing and takes effect before any other selection criteria are applied.
1 perry 41
3 CraigBox 42 The __-a__ option may be used to AND the selections. For example, specifying __-a__ , __-U__ , and __-u__foo produces a listing of only UNIX socket files that belong to processes owned by user "foo".
1 perry 43
3 CraigBox 44 Caution: the __-a__ option causes all list selection options to be ANDed; it can't be used to cause ANDing of selected pairs of selection options by placing it between them, even though its placement there is acceptable. Wherever __-a__ is placed, it causes the ANDing of all selection options.
1 perry 45
3 CraigBox 46 Items of the same selection set - command names, file descriptors, network addresses, process identifiers, user identifiers - are joined in a single ORed set and applied before the result participates in ANDing. Thus, for example, specifying __-i__@aaa.bbb, __-i__@ccc.ddd, __-a__ , and __-u__fff,ggg will select the listing of files that belong to either login "fff" OR "ggg" AND have network connections to either host aaa.bbb OR ccc.ddd.
1 perry 47
3 CraigBox 48 Options may be grouped together following a single prefix -- e.g., the option set "__-a -b -C__" may be stated as __-abC__ . However, since values are optional following __+|-f__ , __-F__ , __-g__ , __-i__ , __+|-L__ , __-o__ , __+|-r__ , __-S__ , and __-T__ , when you have no values for them be careful that the following character isn't ambiguous. For example, __-Fn__ might represent the __-F__ and __-n__ options, or it might represent the __n__ field identifier character following the __-F__ option. When ambiguity is possible, start a new option with a `-' character - e.g., "__-F -n__". If the next option is a file name, follow the possibly ambiguous option with "--" - e.g., "__-F -- ''name''__".
1 perry 49
3 CraigBox 50 Either the `+' or the `-' prefix may be applied to a group of options. Options that don't take on separate meanings for each prefix - e.g., __-i__ - may be grouped under either prefix. Thus, for example, "+M -i" may be stated as "+Mi" and the group means the same as the separate options. Be careful of prefix grouping when one or more options in the group does take on separate meanings under different prefixes - e.g., __+|-M__; "-iM" is not the same request as "-i +M". When in doubt, use separate options with appropriate prefixes.
51 ;__-? -h__ : These two equivalent options select a usage (help) output list. ''Lsof'' displays a shortened form of this output when it detects an error in the options supplied to it, after it has displayed messages explaining each error. (Escape the `?' character as your shell requires.)
52 ;__-a__ : This option causes list selection options to be ANDed, as described above.
53 ;__-A__ '' A'' : This option is available on systems configured for AFS whose AFS kernel code is implemented via dynamic modules. It allows the ''lsof'' user to specify ''A'' as an alternate name list file where the kernel addresses of the dynamic modules might be found. See the ''lsof'' FAQ (The __FAQ__ section gives its location.) for more information about dynamic modules, their symbols, and how they affect ''lsof'' .
54 ;__-b__ : This option causes ''lsof'' to avoid kernel functions that might block - lstat(2), readlink(2), and stat(2).
55 ;: See the __BLOCKS AND TIMEOUTS__ and __AVOIDING KERNEL BLOCKS__ sections for information on using this option.
56 ;__-c__ '' c'' : This option selects the listing of files for processes executing the command that begins with the characters of ''c'' . Multiple commands may be specified, using multiple __-c__ options. They are joined in a single ORed set before participating in AND option selection.
57 ;: If ''c'' begins and ends with a slash ('/'), the characters between the slashes is interpreted as a regular expression. Shell meta-characters in the regular expression must be quoted to prevent their interpretation by the shell. The closing slash may be followed by these modifiers:
58 ;:
59 b the regular expression is a basic one. %%%
1 perry 60
3 CraigBox 61 %%%
62 i ignore the case of letters. %%%
1 perry 63
3 CraigBox 64 %%%
65 x the regular expression is an extended one %%%
1 perry 66
3 CraigBox 67 %%%
68 (default). %%%
1 perry 69
70
3 CraigBox 71 ;: See the ''lsof'' FAQ (The __FAQ__ section gives its location.) for more information on basic and extended regular expressions.
72 ;: The simple command specification is tested first. If that test fails, the command regular expression is applied. If the simple command test succeeds, the command regular expression test isn't made. This may result in "no command found for regex:" messages when lsof's __-V__ option is specified.
73 ;__-C__ : This option disables the reporting of any path name components from the kernel's name cache. See the __KERNEL NAME CACHE__ section for more information.
74 ;__+d__ '' s'' : This option causes ''lsof'' to search for all open instances of directory ''s'' and the files and directories it contains at its top level. This option does NOT descend the directory tree, rooted at ''s'' , nor does it follow symbolic links within it. The __+D__ '' D'' option may be used to request a full-descent directory tree search, rooted at directory ''D'' .
75 ;: Note: the authority of the user of this option limits it to searching for files that the user has permission to examine with the system stat(2) function.
76 ;__-d__ '' s'' : This option selects the listing of files whose file descriptors are in the comma-separated set ''s'' - e.g., "1,3" or "6,cwd,2". (There should be no spaces in the set.)
77 ;: A file descriptor number range may be included in the set as long as neither member is empty, both members are numbers, and the ending member is larger than the starting one - e.g., "0-7" or "3-10".
78 ;: Multiple file descriptor numbers are joined in a single ORed set before participating in AND option selection.
79 ;: See the description of File Descriptor (FD) output values in the __OUTPUT__ section for more information on file descriptor names.
80 ;__+D__ '' D'' : This option causes ''lsof'' to search for all open instances of directory ''D'' and all the files and directories it contains to its complete depth. Symbolic links within directory ''D'' are ignored - i.e, not followed.
81 ;: Note: the authority of the user of this option limits it to searching for files that the user has permission to examine with the system stat(2) function.
82 ;: Further note: ''lsof'' may process this option slowly and require a large amount of dynamic memory to do it. This is because it must descend the entire directory tree, rooted at ''D'' , calling stat(2) for each file and directory, building a list of all the files it finds, and searching that list for a match with every open file. When directory ''D'' is large, these steps can take a long time, so use this option prudently.
83 ;__-D__ '' D'' : This option directs ''lsof's'' use of the device cache file. The use of this option is sometimes restricted. See the __DEVICE CACHE FILE__ section and the sections that follow it for more information on this option.
84 ;: __-D__ must be followed by a function letter; the function letter may optionally be followed by a path name. ''Lsof'' recognizes these function letters:
85 ;:
86 __?__ - report device cache file paths %%%
87 __b__ - build the device cache file %%%
88 __i__ - ignore the device cache file %%%
89 __r__ - read the device cache file %%%
90 __u__ - read and update the device cache file %%%
1 perry 91
92
3 CraigBox 93 ;: The __b__ , __r__ , and __u__ functions, accompanied by a path name, are sometimes restricted. When these functions are restricted, they will not appear in the description of the __-D__ option that accompanies __-h__ or __-?__ option output. See the __DEVICE CACHE FILE__ section and the sections that follow it for more information on these functions and when they're restricted.
94 ;: The __?__ function reports the read-only and write paths that lsof can use for the device cache file, the names of any environment variables whose values ''lsof'' will examine when forming the device cache file path, and the format for the personal device cache file path. (Escape the `?' character as your shell requires.)
95 ;: When available, the __b__ , __r__ , and __u__ functions may be followed by the device cache file's path. The standard default is ''.lsof_hostname'' in the home directory of the real user ID that executes ''lsof'' , but this could have been changed when ''lsof'' was configured and compiled. (The output of the __-h__ and __-?__ options show the current default prefix - e.g., ".lsof".) The suffix, ''hostname'' , is the first component of the host's name returned by gethostname(2) ''.''
96 ;: When available, the __b__ function directs ''lsof'' to build a new device cache file at the default or specified path.
97 ;: The __i__ function directs ''lsof'' to ignore the default device cache file and obtain its information about devices via direct calls to the kernel.
98 ;: The __r__ function directs ''lsof'' to read the device cache at the default or specified path, but prevents it from creating a new device cache file when none exists or the existing one is improperly structured. The __r__ function, when specified without a path name, prevents ''lsof'' from updating an incorrect or outdated device cache file, or creating a new one in its place. The __r__ function is always available when it is specified without a path name argument; it may be restricted by the permissions of the ''lsof'' process.
99 ;: When available, the __u__ function directs ''lsof'' to read the device cache file at the default or specified path, if possible, and to rebuild it, if necessary. This is the default device cache file function when no __-D__ option has been specified. ''lsof'' repetitively from a shell script, for example.
100 ;__+|-f [[cfgGn]__ : __f__ by itself clarifies how path name arguments are to be interpreted. When followed by __c__ , __f__ , __g__ , __G__ , or __n__ in any combination it specifies that the listing of kernel file structure information is to be enabled (`+') or inhibited (`-').
101 ;: Normally a path name argument is taken to be a file system name if it matches a mounted-on directory name reported by mount(8), or if it represents a block device, named in the ''mount'' output and associated with a mounted directory name. When __+f__ is specified, all path name arguments will be taken to be file system names, and ''lsof'' will complain if any are not. This can be useful, for example, when the file system name (mounted-on device) isn't a block device. This happens for some CD-ROM file systems.
102 ;: When __-f__ is specified, all path name arguments will be taken to be simple files. Thus, for example, the "__-f__\ /" arguments direct lsof to search for open files with a `/' path name, not all open files in the `/' (root) file system.
103 ;: Be careful to make sure __+f__ is properly terminated and isn't followed by a character (e.g., of the file or file system name) that might be taken as a parameter. For example, use "--" after __+f__ as in this example.
104 ;:
105 $ lsof +f -- /file/system/name %%%
1 perry 106
107
3 CraigBox 108 ;: The listing of information from kernel file structures, requested with the __+f [[cfgGn]__ option form, is normally inhibited, and is not available for some dialects - e.g., /proc-based Linux. When the prefix to __f__ is a plus sign (`+'), these characters request file structure information:
109 ;:
110 __c__ file structure use count %%%
111 __f__ file structure address %%%
112 __g__ file flag abbreviations %%%
113 __G__ file flags in hexadecimal %%%
114 __n__ file structure node address %%%
1 perry 115
116
3 CraigBox 117 ;: When the prefix is minus (`-') the same characters disable the listing of the indicated values.
118 ;: File structure addresses, use counts, flags, and node addresses may be used to detect more readily identical files inherited by child processes and identical files in use by different processes. ''Lsof'' column output can be sorted by output columns holding the values and listed to identify identical file use, or ''lsof'' field output can be parsed by an AWK or Perl post-filter script.
119 ;__-F__ '' f'' : This option specifies a character list, ''f'' , that selects the fields to be output for processing by another program, and the character that terminates each output field. Each field to be output is specified with a single character in ''f'' . The field terminator defaults to NL, but may be changed to NUL (000). See the __OUTPUT FOR OTHER PROGRAMS__ section for a description of the field identification characters and the field output process.
120 ;: When the field selection character list is empty, all fields are selected and the NL field terminator is used.
121 ;: When the field selection character list contains only a zero (`0'), all fields are selected and the NUL terminator character is used.
122 ;: Other combinations of fields and their associated field terminator character must be set with explicit entries in ''f'' , as described in the __OUTPUT FOR OTHER PROGRAMS__ section.
123 ;: When a field selection character identifies an item ''lsof'' does not normally list - e.g., PPID, selected with __-R__ - specification of the field character - e.g., "__-FR__" - also selects the listing of the item.
124 ;: When the field selection character list contains the single character `?', ''lsof'' will display a help list of the field identification characters. (Escape the `?' character as your shell requires.)
125 ;__-g__ '' [[s]'' : This option selects the listing of files for the processes whose optional process group IDentification (PGID) numbers are in the comma-separated set ''s'' - e.g., "123" or "123,456". (There should be no spaces in the set.)
126 ;: Multiple PGID numbers are joined in a single ORed set before participating in AND option selection.
127 ;: The __-g__ option also enables the output display of PGID numbers. When specified without a PGID set that's all it does.
128 ;__-i__ '' [[i]'' : This option selects the listing of files any of whose Internet address matches the address specified in ''i''. If no address is specified, this option selects the listing of all Internet and x.25 (HP-UX) network files.
129 ;: Multiple addresses (up to a limit of 100) may be specified with multiple __-i__ options. (A port number or service name range is counted as one address.) They are joined in a single ORed set before participating in AND option selection.
130 ;: An Internet address is specified in the form:
131 ;: [[''protocol''][[@''hostname''|''hostaddr''][[:''service''|''port'']
132 ;: where:
1 perry 133
3 CraigBox 134 ''protocol'' is a protocol name - __TCP__ or __UDP__. %%%
135 ''hostname'' is an Internet host name. %%%
136 ''hostaddr'' is a numeric Internet IPv4 address in dot form; or an IPv6 numeric address in colon form, enclosed in brackets. %%%
137 ''service'' is an ''/etc/services'' name - e.g., __smtp__ - or list of them. %%%
138 ''port'' is a port number, or list of them. %%%
1 perry 139
3 CraigBox 140 ;: IPv6 numeric host addresses may be specified only if the UNIX dialect supports them. To see if the dialect supports IPv6 addresses, run ''lsof'' and specify the __-h__ or __-?__ (help) option. If the displayed description of the __-i__ option contains "IPv[[46]", IPv6 addresses are supported.
141 ;: At least one address component - ''protocol'' , host specification, service or port specification - must be supplied. The `@' character, leading the host specification, is always required; as is the `:', leading the port specification. Specify either ''hostname'' or ''hostaddr'' . Specify either ''service'' name list or ''port'' number list. If a ''service'' name list is specified, the ''protocol'' may also need to be specified if the TCP and UDP port numbers for the service name are different. Use any case - lower or upper - for ''protocol'' .
142 ;: ''Service'' names and ''port'' numbers may be combined in a list whose entries are separated by commas and whose numeric range entries are separated by minus signs. There may be no embedded spaces, and all service names must belong to the specified ''protocol'' . Since service names may contain embedded minus signs, the staring entry of a range can't be a service name; it can be a port number, however.
143 ;: Here are some sample addresses:
1 perry 144
145
3 CraigBox 146 %%%
1 perry 147
3 CraigBox 148 %%%
149 TCP:25 - TCP and port 25 %%%
1 perry 150
3 CraigBox 151 %%%
152 @1.2.3.4 - Internet IPv4 host address 1.2.3.4 %%%
1 perry 153
3 CraigBox 154 %%%
155 @[[3ffe:1ebc::1]:1234 - Internet IPv6 host address %%%
156 3ffe:1ebc::1, port 1234 %%%
1 perry 157
3 CraigBox 158 %%%
159 UDP:who - UDP who service port %%%
1 perry 160
3 CraigBox 161 %%%
162 TCP@vic.cc:513 - TCP, port 513 and host name vic.cc %%%
1 perry 163
3 CraigBox 164 %%%
165 tcp@foo:1-10,smtp,99 - TCP, ports 1 through 10, %%%
166 service name ''smtp'', port 99, host name foo %%%
1 perry 167
3 CraigBox 168 %%%
169 tcp@bar:smtp-nameserver - TCP, ports ''smtp'' through %%%
170 ''nameserver'', host bar %%%
1 perry 171
3 CraigBox 172 %%%
173 :time - either TCP or UDP time service port %%%
1 perry 174
175
3 CraigBox 176 ;__-k__ '' k'' : This option specifies a kernel name list file, ''k'' , in place of /vmunix, /mach, etc. This option is not available under AIX on the IBM RISC/System 6000.
177 ;__-l__ : This option inhibits the conversion of user ID numbers to login names. It is also useful when login name lookup is working improperly or slowly.
178 ;__+|-L__ '' [[l]'' : This option enables (`+') or disables (`-') the listing of file link counts, where they are available - e.g., they aren't available for sockets, or most FIFOs and pipes.
179 ;: When __+L__ is specified without a following number, all link counts will be listed. When __-L__ is specified (the default), no link counts will be listed.
180 ;: When __+L__ is followed by a number, only files having a link count less than that number will be listed. (No number may follow __-L__ .) A specification of the form "__+L1__" will select open files that have been unlinked. A specification of the form "__+aL1\ ''<file_system>''__" will select unlinked open files on the specified file system.
181 ;: For other link count comparisons, use field output (__-F__) and a post-processing script.
182 ;__-m__ '' m'' : This option specifies a kernel memory file, ''c'' , in place of ''/dev/kmem'' or ''/dev/mem'' - e.g., a crash dump file.
183 ;__+|-M__ : Enables (__+__) or disables (__-__) the reporting of portmapper registrations for local TCP and UDP ports. The default reporting mode is set by the ''lsof'' builder with the HASPMAPENABLED #define in the dialect's machine.h header file; ''lsof'' is distributed with the HASPMAPENABLED #define deactivated, so portmapper reporting is disabled by default and must be requested with __+M__ . Specifying ''lsof's'' __-h__ or __-?__ option will report the default mode. Disabling portmapper registration when it is already disabled or enabling it when already enabled is acceptable. in a warning.
184 ;: When portmapper registration reporting is enabled, ''lsof'' displays the portmapper registration (if any) for local TCP or UDP ports in square brackets immediately following the port numbers or service names - e.g., ":1234[[name]" or ":name[[100083]". The registration information may be a name or number, depending on what the registering program supplied to the portmapper when it registered the port.
185 ;: When portmapper registration reporting is enabled, ''lsof'' may run a little more slowly or even become blocked when access to the portmapper becomes congested or stopped. Reverse the reporting mode to determine if portmapper registration reporting is slowing or blocking ''lsof'' .
186 ;: For purposes of portmapper registration reporting ''lsof'' considers a TCP or UDP port local if: it is found in the local part of its containing kernel structure; or if it is located in the foreign part of its containing kernel structure and the local and foreign Internet addresses are the same; or if it is located in the foreign part of its containing kernel structure and the foreign Internet address is INADDR_LOOPBACK (127.0.0.1). This rule may make ''lsof'' ignore some foreign ports on machines with multiple interfaces when the foreign Internet address is on a different interface from the local one.
187 ;: See the ''lsof'' FAQ (The __FAQ__ section gives its location.) for further discussion of portmapper registration reporting issues.
188 ;__-n__ : This option inhibits the conversion of network numbers to host names for network files. Inhibiting conversion may make ''lsof'' run faster. It is also useful when host name lookup is not working properly.
189 ;__-N__ : This option selects the listing of NFS files.
190 ;__-o__ : This option directs ''lsof'' to display file offset at all times. It causes the SIZE/OFF output column title to be changed to OFFSET. Note: on some UNIX dialects ''lsof'' can't obtain accurate or consistent file offset information from its kernel data sources, sometimes just for particular kinds of files (e.g., socket files.) Consult the ''lsof'' FAQ (The __FAQ__ section gives its location.) for more information.
191 ;: The __-o__ and __-s__ options are mutually exclusive; they can't both be specified. When neither is specified, ''lsof'' displays whatever value - size or offset - is appropriate and available for the type of the file.
192 ;__-o__ '' o'' : This option defines the number of decimal digits (''o'') to be printed after the "0t" for a file offset before the form is switched to "0x...". An ''o'' value of zero (unlimited) directs ''lsof'' to use the "0t" form for all offset output.
193 ;: This option does NOT direct ''lsof'' to display offset at all times; specify __-o__ (without a trailing number) to do that. This option only specifies the number of digits after "0t" in either mixed size and offset or offset-only output. Thus, for example, to direct ''lsof'' to display offset at all times with a decimal digit count of 10, use:
194 ;:
195 -o -o 10 %%%
196 or %%%
197 -oo10 %%%
1 perry 198
199
3 CraigBox 200 ;: The default number of digits allowed after "0t" is normally 8, but may have been changed by the lsof builder. Consult the description of the __-o__ '' o'' option in the output of the __-h__ or __-?__ option to determine the default that is in effect.
201 ;__-O__ : This option directs ''lsof'' to bypass the strategy it uses to avoid being blocked by some kernel operations - i.e., doing them in forked child processes. See the __BLOCKS AND TIMEOUTS__ and __AVOIDING KERNEL BLOCKS__ sections for more information on kernel operations that may block ''lsof'' .
202 ;: While use of this option will reduce ''lsof'' startup overhead, it may also cause ''lsof'' to hang when the kernel doesn't respond to a function. Use this option cautiously.
203 ;__-p__ '' s'' : This option selects the listing of files for the processes whose ID numbers are in the comma-separated set ''s'' - e.g., "123" or "123,456". (There should be no spaces in the set.)
204 ;: Multiple process ID numbers are joined in a single ORed set before participating in AND option selection.
205 ;__-P__ : This option inhibits the conversion of port numbers to port names for network files. Inhibiting the conversion may make ''lsof'' run a little faster. It is also useful when host name lookup is not working properly.
206 ;__+|-r__ '' [[t]'' : This option puts ''lsof'' in repeat mode. There ''lsof'' lists open files as selected by other options, delays ''t'' seconds (default fifteen), then repeats the listing, delaying and listing repetitively until stopped by a condition defined by the prefix to the option.
207 ;: If the prefix is a `-', repeat mode is endless. ''Lsof'' must be terminated with an interrupt or quit signal.
208 ;: If the prefix is `+', repeat mode will end the first cycle no open files are listed - and of course when ''lsof'' is stopped with an interrupt or quit signal. When repeat mode ends because no files are listed, the process exit code will be zero if any open files were ever listed; one, if none were ever listed.
209 ;: ''Lsof'' marks the end of each listing: if field output is in progress (the __-F__ , option has been specified), the marker is `m'; otherwise the marker is "========". The marker is followed by a NL character.
210 ;: Repeat mode reduces ''lsof'' startup overhead, so it is more efficient to use this mode than to call ''lsof'' repetitively from a shell script, for example.
211 ;: To use repeat mode most efficiently, accompany __+|-r__ with specification of other ''lsof'' selection options, so the amount of kernel memory access ''lsof'' does will be kept to a minimum. Options that filter at the process level - e.g., __-c__ , __-g__ , __-p__ , __-u__ - are the most efficient selectors.
212 ;: Repeat mode is useful when coupled with field output (see the __-F__ , option description) and a supervising ''awk'' or ''Perl'' script.
213 ;__-R__ : This option directs lsof to list the Parent Process IDentification number in the PPID column.
214 ;__-s__ : This option directs ''lsof'' to display file size at all times. It causes the SIZE/OFF output column title to be changed to SIZE. If the file does not have a size, nothing is displayed.
215 ;: The __-o__ (without a following decimal digit count) and __-s__ options are mutually exclusive; they can't both be specified. When neither is specified, ''lsof'' displays whatever value - size or offset - is appropriate and available for the type of file.
216 ;: Since some types of files don't have true sizes - sockets, FIFOs, pipes, etc. - lsof displays for their sizes the content amounts in their associated kernel buffers, if possible.
217 ;__-S__ '' [[t]'' : This option specifies an optional time-out seconds value for kernel functions - lstat(2), readlink(2), and stat(2) - that might otherwise deadlock. The minimum for ''t'' is two; the default, fifteen; when no value is specified, the default is used.
218 ;: See the __BLOCKS AND TIMEOUTS__ section for more information.
219 ;__-T__ '' [[t]'' : This option controls the reporting of some TCP/TPI information, also reported by netstat(1), following the network addresses. In normal output the information appears in parentheses, each item except state identified by a keyword, followed by `=', separated from others by a single space:
220 ;:
221 <TCP or TPI state name> %%%
222 QR=<read queue length> %%%
223 QS=<send queue length> %%%
224 WR=<window read length> (not all dialects) %%%
225 WW=<window write length> (not all dialects) %%%
1 perry 226
227
3 CraigBox 228 ;: When the field output mode is in effect (See __OUTPUT FOR OTHER PROGRAMS__ .) each item appears as a field with a `T' leading character, and the TCP or TPI state name has the prefix "ST=".
229 ;: __-T__ with no following key characters disables TCP/TPI information reporting.
230 ;: __-T__ with following characters selects the reporting of specific TCP/TPI information:
231 ;:
232 __q__ selects queue length reporting. %%%
233 __s__ selects state reporting. %%%
234 __w__ selects window size reporting (not %%%
235 all dialects). %%%
1 perry 236
237
3 CraigBox 238 ;: State is reported by default. The __-h__ or __-?__ help output for the __-T__ option will show whether window size reporting can be requested.
239 ;: When __-T__ is used to select information - i.e., it is followed by one or more selection characters - the displaying of state is disabled by default, and it must be explicitly selected again in the characters following __-T__ . (In effect, then, the default is equivalent to __-Ts__ .) For example, if queue lengths and state are desired, use __-Tqs__ .
240 ;__-t __ : This option specifies that ''lsof'' should produce terse output with process identifiers only and no header - e.g., so that the output may be piped to kill(1). This option selects the __-w__ option.
241 ;__-u__ '' s'' : This option selects the listing of files for the user whose login names or user ID numbers are in the comma-separated set ''s'' - e.g., "abe", or "548,root". (There should be no spaces in the set.)
242 ;: Multiple login names or user ID numbers are joined in a single ORed set before participating in AND option selection.
243 ;: If a login name or user ID is preceded by a `^', it becomes a negation - i.e., files of processes owned by the login name or user ID will never be listed. A negated login name or user ID selection is neither ANDed nor ORed with other selections; it is applied before all other selections and absolutely excludes the listing of the files of the process. For example, to direct ''lsof'' to exclude the listing of files belonging to root processes, specify "-u^root" or "-u^0".
244 ;__-U__ : This option selects the listing of UNIX domain socket files.
245 ;__-v__ : This option selects the listing of ''lsof'' version information, including: revision number; when the ''lsof'' binary was constructed; who constructed the binary and where; the name of the compiler used to construct the ''lsof binary;'' the version number of the compiler when readily available; the compiler and loader flags used to construct the ''lsof'' binary; and system information, typically the output of ''uname'' 's __-a__ option.
246 ;__-V__ : This option directs ''lsof'' to indicate the items it was asked to list and failed to find - command names, file names, Internet addresses or files, login names, NFS files, PIDs, PGIDs, and UIDs.
247 ;: When other options are ANDed to search options, ''lsof'' may not report that it failed to find a search item when an ANDed option prevents the listing of the open file containing the located search item. For example, "lsof -V -iTCP@foobar -a -d 999" may not report a failure to locate open files at "TCP@foobar" and may not list any, if none have a file descriptor number of 999.
248 ;__+|-w__ : Enables (__+__) or disables (__-__) the suppression of warning messages.
249 ;: The ''lsof'' builder may choose to have warning messages disabled or enabled by default. The default warning message state is indicated in the output of the __-h__ or __-?__ option. Disabling warning messages when they are already disabled or enabling them when already enabled is acceptable.
250 ;: The __-t__ option selects the __-w__ option.
251 ;__-X__ : This is a dialect-specific option. \w'names'u+4 \ \ \ \ AIX:
252 __WARNING:__ use of this option on a busy AIX system might cause an application process to hang so completely that it can neither be killed nor stopped. I have never seen this happen or had a report of it, but I think the possibility exists.
253 ;: This IBM AIX RISC/System 6000 __-X__ option directs ''lsof'' to use the kernel readx() function. (By default use of readx() is disabled.) On AIX 5L and above ''lsof'' may need setuid-root permission to perform the actions this option requests.
254 ;: The ''lsof'' builder may specify that the __-X__ option be restricted to processes whose real UID is root. If that has been done, the __-X__ option will not appear in the __-h__ or __-?__ help output unless the real UID of the ''lsof'' process is root. The default ''lsof'' distribution allows any UID to specify __-X,__ so by default it will appear in the help output.
255 ;: When AIX readx() use is disabled, ''lsof'' may not be able to report information for all text and loader file references, but it may also avoid exacerbating an AIX kernel directory search kernel error, known as the Stale Segment ID bug.
256 ;: When readx() is enabled, ''lsof'' will attempt to report information on the text file being executed by each process and the shared libraries it uses.
257 ;: The readx() function, used by ''lsof'' or any other program, to access some sections of kernel virtual memory, can trigger the Stale Segment ID bug. It can cause the kernel's dir_search() function erroneously to believe that part of an in-memory copy of a file system directory has been zeroed. Another application process, distinct from ''lsof'' , asking the kernel to search the directory - e.g., by using open(2) - can cause dir_search() to loop forever, thus hanging the application process.
258 ;: Consult the ''lsof'' FAQ (The __FAQ__ section gives its location.) and the ''00README'' file of the ''lsof'' distribution for a more complete description of the Stale Segment ID bug, its APAR, and methods for defining readx() use when compiling ''lsof'' . \w'names'u+4 \ \ \ \ PTX:
259 This Sequent PTX __-X__ option directs ''lsof'' to list the file use count and inode address from the file structure. Its effect is equivalent to __+fcf__ with these exceptions: the NODE-ID column title will be changed to INODE-ADDR; and the only value listed in the INODE-ADDR column will be the kernel inode structure address for files that use an inode.
260 ;: The file use count (decimal) indicates the number of concurrent users of the file descriptor. The kernel inode address (hexadecimal) is a value sometimes useful when working with a malfunctioning system. (Also see the manual page for the PTX crash(1) application.)
261 ;__--__ : The double minus sign option is a marker that signals the end of the keyed options. It may be used, for example, when the first file name begins with a minus sign. It may also be used when the absence of a value for the last keyed option must be signified by the presence of a minus sign in the following option and before the start of the file names.
262 ;''names'' : These are path names of specific files to list. Symbolic links are resolved before use. The first name may be separated from the preceding options with the "--" option.
263 ;: If a ''name '' is the mounted-on directory of a file system or the device of the file system, ''lsof'' will list all the files open on the file system. To be considered a file system, the ''name'' must match a mounted-on directory name in mount(8) output, or match the name of a block device associated with a mounted-on directory name. The __+|-f__ option may be used to force ''lsof'' to consider a ''name'' a file system identifier (__+f__) or a simple file (__-f__).
264 ;: If ''name'' is a path to a directory that is not the mounted-on directory name of a file system, it is treated just as a regular file is treated - i.e., its listing is restricted to processes that have it open as a file or as a process-specific directory, such as the root or current working directory. To request that ''lsof'' look for open files inside a directory name, use the __+d__ '' s'' and __+D__ '' D'' options.
265 ;: If a ''name'' is the base name of a family of multiplexed files - e. g, AIX's ''/dev/pt[[cs]'' - ''lsof'' will list all the associated multipled files on the device that are open - e.g., ''/dev/pt[[cs]/1'' , ''/dev/pt[[cs]/2'' , etc.
266 ;: If a ''name'' is a UNIX domain socket name, ''lsof'' will search for it by the characters of the name alone - exactly as it is specified and is recorded in the kernel socket structure. Specifying a relative path - e.g., ''./file'' - in place of the file's absolute path - e.g., ''/tmp/file'' - won't work because ''lsof'' must match the characters you specify with what it finds in the kernel UNIX domain socket structures.
267 ;: If a ''name'' is none of the above, ''lsof'' will list any open files whose device and inode match that of the specified path ''name'' .
268 ;: If you have also specified the __-b__ option, the only ''names'' you may safely specify are file systems for which your mount table supplies alternate device numbers. See the __AVOIDING KERNEL BLOCKS__ and __ALTERNATE DEVICE NUMBERS__ sections for more information.
269 ;: Multiple file names are joined in a single ORed set before participating in AND option selection.
1 perry 270
3 CraigBox 271 !!AFS
272 ''Lsof'' supports the recognition of AFS files for these dialects (and AFS versions):
1 perry 273
274
3 CraigBox 275 AIX 4.1.4 (AFS 3.4a) %%%
276 HP-UX 9.0.5 (AFS 3.4a) %%%
277 Linux 1.2.13 (AFS 3.3) %%%
278 Solaris 2.[[56] (AFS 3.4a) %%%
279 Ultrix 4.2 RISC (AFS 3.2b) (no longer available) %%%
1 perry 280
281
282
283 It may recognize AFS files on other versions of these dialects, but has not been tested there. Depending on how AFS is implemented, ''lsof'' may recognize AFS files in other dialects, or may have difficulties recognizing AFS files in the supported dialects.
284
3 CraigBox 285 ''Lsof'' may have trouble identifying all aspects of AFS files in supported dialects when AFS kernel support is implemented via dynamic modules whose addresses do not appear in the kernel's variable name list. In that case, ''lsof'' may have to guess at the identity of AFS files, and might not be able to obtain volume information from the kernel that is needed for calculating AFS volume node numbers. When ''lsof'' can't compute volume node numbers, it reports blank in the NODE column.
1 perry 286
3 CraigBox 287 The __-A__ '' A'' option is available in some dialect implementations of ''lsof'' for specifying the name list file where dynamic module kernel addresses may be found. When this option is available, it will be listed in the ''lsof'' help output, presented in response to the __-h__ or __-?__
1 perry 288
3 CraigBox 289 See the ''lsof'' FAQ (The __FAQ__ section gives its location.) for more information about dynamic modules, their symbols, and how they affect ''lsof'' options.
1 perry 290
3 CraigBox 291 Because AFS path lookups don't seem to participate in the kernel's name cache operations, ''lsof'' can't identify path name components for AFS files.
1 perry 292
293 !!SECURITY
3 CraigBox 294 ''Lsof'' has three features that may cause security concerns. First, its default compilation mode allows anyone to list all open files with it. Second, by default it creates a user-readable and user-writable device cache file in the home directory of the real user ID that executes ''lsof'' . (The list-all-open-files and device cache features may be disabled when ''lsof'' is compiled.) Third, its __-k__ and __-m__ options name alternate kernel name list or memory files.
1 perry 295
3 CraigBox 296 Restricting the listing of all open files is controlled by the compile-time HASSECURITY option. When HASSECURITY is defined, ''lsof'' will allow only the root user to list all open files. The non-root user may list only open files of processes with the same user IDentification number as the real user ID number of the ''lsof'' process (the one that its user logged on with). When HASSECURITY is not defined, anyone may list all open files.
1 perry 297
3 CraigBox 298 Help output, presented in response to the __-h__ or __-?__ option, gives the HASSECURITY definition status.
1 perry 299
3 CraigBox 300 See the __Security__ section of the ''0README'' file of the ''lsof'' distribution for information on building ''lsof'' with the HASSECURITY option enabled.
1 perry 301
3 CraigBox 302 Creation and use of a user-readable and user-writable device cache file is controlled by the compile-time HASDCACHE option. See the __DEVICE CACHE FILE__ section and the sections that follow it for details on how its path is formed. For security considerations it is important to note that in the default ''lsof'' distribution, if the real user ID under which ''lsof'' is executed is root, the device cache file will be written in root's home directory - e.g., ''/'' or ''/root'' . When HASDCACHE is not defined, ''lsof'' does not write or attempt to read a device cache file.
1 perry 303
3 CraigBox 304 When HASDCACHE is defined, the ''lsof'' help output, presented in response to the __-h__ , __-D?__ , or __-?__ options, will provide device cache file handling information. When HASDCACHE is not defined, the __-h__ or __-?__ output will have no __-D__ option description.
1 perry 305
3 CraigBox 306 Before you decide to disable the device cache file feature - enabling it improves the performance of ''lsof'' by reducing the startup overhead of examining all the nodes in ''/dev'' (or ''/devices'' ) - read the discussion of it in the ''00DCACHE'' file of the ''lsof'' distribution and the ''lsof'' FAQ (The __FAQ__ section gives its location.)
1 perry 307
3 CraigBox 308 WHEN IN DOUBT, YOU CAN TEMPORARILY DISABLE THE USE OF THE DEVICE CACHE FILE WITH THE __-Di__ OPTION.
1 perry 309
3 CraigBox 310 When ''lsof'' user declares alternate kernel name list or memory files with the __-k__ and __-m__ options, ''lsof'' checks the user's authority to read them with access(2). This is intended to prevent whatever special power ''lsof's'' modes might confer on it from letting it read files not normally accessible via the authority of the real user ID.
1 perry 311
312 !!OUTPUT
3 CraigBox 313 This section describes the information ''lsof'' lists for each open file. See the __OUTPUT FOR OTHER PROGRAMS__ section for additional information on output that can be processed by another program.
1 perry 314
3 CraigBox 315 ''Lsof'' only outputs printable (declared so by isprint(3)) ASCII characters. Non-printable characters are printed in one of three forms: the C "\[[bfrnt]" form; the control character `^' form (e.g., "^@"); or hexadecimal leading "\x" form (e.g., "\xab"). Space is non-printable in the COMMAND column ("\x20") and printable elsewhere.
1 perry 316
3 CraigBox 317 ''Lsof'' dynamically sizes the output columns each time it runs, guaranteeing that each column is a minimum size. It also guarantees that each column is separated from its predecessor by at least one space.
318 ;COMMAND : contains the first nine characters of the name of the UNIX command associated with the process.
319 ;: All command name characters maintained by the kernel in its structures are displayed in field output when the command name descriptor (`c') is specified. See the __OUTPUT FOR OTHER COMMANDS__ section for information on selecting field output and the associated command name descriptor.
320 ;PID : is the Process IDentification number of the process.
321 ;PPID : is the Parent Process IDentification number of the process. It is only displayed when the __-R__ option has been specified.
322 ;PGID : is the process group IDentification number associated with the process. It is only displayed when the __-g__ option has been specified.
323 ;USER : is the user ID number or login name of the user to whom the process belongs, as reported by ps(1). (See the __-l__ option description.)
324 ;FD : is the File Descriptor number of the file or:
325 ;:
326 __cwd__ current working directory; %%%
1 perry 327
3 CraigBox 328 %%%
329 __L''nn''__ library references (AIX); %%%
1 perry 330
3 CraigBox 331 %%%
332 __jld__ jail directory (FreeBSD); %%%
1 perry 333
3 CraigBox 334 %%%
335 __ltx__ shared library text (code and data); %%%
1 perry 336
3 CraigBox 337 %%%
338 __Mxx__ hex memory-mapped type number xx. %%%
1 perry 339
3 CraigBox 340 %%%
341 __m86__ DOS Merge mapped file; %%%
1 perry 342
3 CraigBox 343 %%%
344 __mem__ memory-mapped file; %%%
1 perry 345
3 CraigBox 346 %%%
347 __mmap__ memory-mapped device; %%%
1 perry 348
3 CraigBox 349 %%%
350 __pd__ parent directory; %%%
1 perry 351
3 CraigBox 352 %%%
353 __rtd__ root directory; %%%
1 perry 354
3 CraigBox 355 %%%
356 __txt__ program text (code and data); %%%
1 perry 357
3 CraigBox 358 %%%
359 __v86__ VP/ix mapped file; %%%
1 perry 360
361
3 CraigBox 362 ;: FD is followed by one of these characters, describing the mode under which the file is open:
363 ;: __r__ for read access;
364 __w__ for write access;
365 __u__ for read and write access;
366 space if mode unknown and no lock
367 character follows;
368 `-' if mode unknown and lock
369 character follows.
370 ;: The mode character is followed by one of these lock characters, describing the type of lock applied to the file:
371 ;: __N__ for a Solaris NFS lock of unknown type;
372 __r__ for read lock on part of the file;
373 __R__ for a read lock on the entire file;
374 __w__ for a write lock on part of the file;
375 __W__ for a write lock on the entire file;
376 __u__ for a read and write lock of any length;
377 __U__ for a lock of unknown type;
378 __x__ for an SCO !OpenServer Xenix lock on part of the file;
379 __X__ for an SCO !OpenServer Xenix lock on the entire file;
380 space if there is no lock.
381 ;: See the __LOCKS__ section for more information on the lock information character.
382 ;: The FD column contents constitutes a single field for parsing in post-processing scripts.
383 ;TYPE : is the type of the node associated with the file - e.g., GDIR, GREG, VDIR, VREG, etc.
384 ;: or "IPv4" for an IP version 4 socket;
385 ;: or "IPv6" for an IP version 6 socket - even if its address is IPv4, mapped to IPv6;
386 ;: or "ax25" for a Linux AX.25 socket;
387 ;: or "inet" for an Internet domain socket;
388 ;: or "lla" for a HP-UX link level access file;
389 ;: or "rte" for an AF_ROUTE socket;
390 ;: or "sock" for a socket of unknown domain;
391 ;: or "unix" for a UNIX domain socket;
392 ;: or "x.25" for an HP-UX x.25 socket;
393 ;: or "BLK" for a block special file;
394 ;: or "CHR" for a character special file;
395 ;: or "DEL" for a Linux map file that has been deleted;
396 ;: or "DIR" for a directory;
397 ;: or "DOOR" for a VDOOR file;
398 ;: or "FIFO" for a FIFO special file;
399 ;: or "LINK" for a symbolic link file;
400 ;: or "MPB" for a multiplexed block file;
401 ;: or "MPC" for a multiplexed character file;
402 ;: or "PAS" for a ''/proc/as'' file;
403 ;: or "PAXV" for a ''/proc/auxv'' file;
404 ;: or "PCRE" for a ''/proc/cred'' file;
405 ;: or "PCTL" for a ''/proc'' control file;
406 ;: or "PCUR" for the current ''/proc'' process;
407 ;: or "PCWD" for a ''/proc'' current working directory;
408 ;: or "PDIR" for a ''/proc'' directory;
409 ;: or "PETY" for a ''/proc'' executable type (''etype'');
410 ;: or "PFD" for a ''/proc'' file descriptor;
411 ;: or "PFDR" for a ''/proc'' file descriptor directory;
412 ;: or "PFIL" for an executable ''/proc'' file;
413 ;: or "PFPR" for a ''/proc'' FP register set;
414 ;: or "PGD" for a ''/proc/pagedata'' file;
415 ;: or "PGID" for a ''/proc'' group notifier file;
416 ;: or "PIPE" for pipes;
417 ;: or "PLC" for a ''/proc/lwpctl'' file;
418 ;: or "PLDR" for a ''/proc/lpw'' directory;
419 ;: or "PLDT" for a ''/proc/ldt'' file;
420 ;: or "PLPI" for a ''/proc/lpsinfo'' file;
421 ;: or "PLST" for a ''/proc/lstatus'' file;
422 ;: or "PLU" for a ''/proc/lusage'' file;
423 ;: or "PLWG" for a ''/proc/gwindows'' file;
424 ;: or "PLWI" for a ''/proc/lwpsinfo'' file;
425 ;: or "PLWS" for a ''/proc/lwpstatus'' file;
426 ;: or "PLWU" for a ''/proc/lwpusage'' file;
427 ;: or "PLWX" for a ''/proc/xregs'' file'
428 ;: or "PMAP" for a ''/proc'' map file (''map'');
429 ;: or "PMEM" for a ''/proc'' memory image file;
430 ;: or "PNTF" for a ''/proc'' process notifier file;
431 ;: or "POBJ" for a ''/proc/object'' file;
432 ;: or "PODR" for a ''/proc/object'' directory;
433 ;: or "POLP" for an old format ''/proc'' light weight process file;
434 ;: or "POPF" for an old format ''/proc'' PID file;
435 ;: or "POPG" for an old format ''/proc'' page data file;
436 ;: or "PORT" for a SYSV named pipe;
437 ;: or "PREG" for a ''/proc'' register file;
438 ;: or "PRMP" for a ''/proc/rmap'' file;
439 ;: or "PRTD" for a ''/proc'' root directory;
440 ;: or "PSGA" for a ''/proc/sigact'' file;
441 ;: or "PSIN" for a ''/proc/psinfo'' file;
442 ;: or "PSTA" for a ''/proc'' status file;
443 ;: or "PUSG" for a ''/proc/usage'' file;
444 ;: or "PW" for a ''/proc/watch'' file;
445 ;: or "PXMP" for a ''/proc/xmap'' file;
446 ;: or "REG" for a regular file;
447 ;: or "SMT" for a shared memory transport file;
448 ;: or "STSO" for a stream socket;
449 ;: or "UNNM" for an unnamed type file.
450 ;FILE-ADDR : contains the kernel file structure address when __f__ has been specified to __+f__ ;
451 ;FCT : contains the file reference count from the kernel file structure when __c__ has been specified to __+f__ ;
452 ;FILE-FLAG : when __g__ or __G__ has been specified to __+f__ , this field contains the contents of the f_flag[[s] member of the kernel file structure and the kernel's per-process open file flags (if available); `G' causes them to be displayed in hexadecimal; `g', as short-hand names; two lists may be displayed with entries separated by commas, the lists separated by a semicolon (`;'); the first list may contain short-hand names for f_flag[[s] values from the following table:
453 ;:
454 AIO asynchronous I/O (e.g., FAIO) %%%
455 AP append %%%
456 ASYN asynchronous I/O (e.g., FASYNC) %%%
457 BAS block, test, and set in use %%%
458 BKIU block if in use %%%
459 BL use block offsets %%%
460 BSK block seek %%%
461 CA copy avoid %%%
462 CLON clone %%%
463 CLRD CL read %%%
464 CR create %%%
465 DF defer %%%
466 DFI defer IND %%%
467 DFLU data flush %%%
468 DIR direct %%%
469 DLY delay %%%
470 DOCL do clone %%%
471 DSYN data-only integrity %%%
472 EX open for exec %%%
473 EXCL exclusive open %%%
474 FSYN synchronous writes %%%
475 GCDF defer during unp_gc() (AIX) %%%
476 GCMK mark during unp_gc() (AIX) %%%
477 GTTY accessed via /dev/tty %%%
478 HUP HUP in progress %%%
479 KERN kernel %%%
480 KIOC kernel-issued ioctl %%%
481 LCK has lock %%%
482 LG large file %%%
483 MBLK stream message block %%%
484 MK mark %%%
485 MNT mount %%%
486 MSYN multiplex synchronization %%%
487 NB non-blocking I/O %%%
488 NBDR no BDRM check %%%
489 NBIO SYSV non-blocking I/O %%%
490 NBF n-buffering in effect %%%
491 NC no cache %%%
492 ND no delay %%%
493 NDSY no data synchronization %%%
494 NET network %%%
495 NMFS NM file system %%%
496 NOTO disable background stop %%%
497 NSH no share %%%
498 NTTY no controlling TTY %%%
499 OLRM OLR mirror %%%
500 PAIO POSIX asynchronous I/O %%%
501 PP POSIX pipe %%%
502 R read %%%
503 RAIO Reliant UNIX RAIO request %%%
504 RC file and record locking cache %%%
505 REV revoked %%%
506 RSH shared read %%%
507 RSYN read synchronization %%%
508 SL shared lock %%%
509 SOCK socket %%%
510 SQSH Sequent shared set on open %%%
511 SQSV Sequent SVM set on open %%%
512 SQR Sequent set repair on open %%%
513 SQS1 Sequent full shared open %%%
514 SQS2 Sequent partial shared open %%%
515 STPI stop I/O %%%
516 SWR synchronous read %%%
517 SYN file integrity while writing %%%
518 TCPM avoid TCP collision %%%
519 TR truncate %%%
520 W write %%%
521 WKUP parallel I/O synchronization %%%
522 WTG parallel I/O synchronization %%%
523 VH vhangup pending %%%
524 VTXT virtual text %%%
525 XL exclusive lock %%%
1 perry 526
527
3 CraigBox 528 ;: this list of names was derived from F* #define's in dialect header files <fcntl.h>, <linux</fs.h>, sys/fcntl.c>, <sys/fcntlcom.h>, and <sys/file.h>; see the lsof.h header file for a list showing the correspondence between the above short-hand names and the header file definitions;
529 ;: the second list (after the semicolon) may contain short-hand names for kernel per-process open file flags from this table:
530 ;:
531 ALLC allocated %%%
532 BR the file has been read %%%
533 BHUP activity stopped by SIGHUP %%%
534 BW the file has been written %%%
535 CLSG closing %%%
536 CX close-on-exec (see fcntl(F_SETFD)) %%%
537 MP memory-mapped %%%
538 LCK lock was applied %%%
539 RSVW reserved wait %%%
540 SHMT UF_FSHMAT set (AIX) %%%
541 USE in use (multi-threaded) %%%
1 perry 542
543
3 CraigBox 544 ;NODE-ID : (or INODE-ADDR for some dialects) contains a unique identifier for the file node (usually the kernel vnode or inode address, but also occasionally a concatenation of device and node number) when __n__ has been specified to __+f__ ;
545 ;DEVICE : contains the device numbers, separated by commas, for a character special, block special, regular, directory or NFS file;
546 ;: or "memory" for a memory file system node under DEC OSF/1, Digital UNIX, or Tru64 UNIX;
547 ;: or the address of the private data area of a Solaris socket stream;
548 ;: or a kernel reference address that identifies the file (The kernel reference address may be used for FIFO's, for example.);
549 ;: or the base address or device name of a Linux AX.25 socket device.
550 ;: Usually only the lower thirty two bits of DEC OSF/1, Digital UNIX, or Tru64 UNIX kernel addresses are displayed.
551 ;SIZE, SIZE/OFF, or OFFSET : is the size of the file or the file offset in bytes. A value is displayed in this column only if it is available. ''Lsof'' displays whatever value - size or offset - is appropriate for the type of the file and the version of ''lsof'' .
552 ;: On some UNIX dialects ''lsof'' can't obtain accurate or consistent file offset information from its kernel data sources, sometimes just for particular kinds of files (e.g., socket files.) In other cases, files don't have true sizes - e.g., sockets, FIFOs, pipes - so ''lsof'' displays for their sizes the content amounts it finds in their kernel buffer descriptors (e.g., socket buffer size counts or TCP/IP window sizes.) Consult the ''lsof'' FAQ (The __FAQ__ section gives its location.) for more information.
553 ;: The file size is displayed in decimal; the offset is normally displayed in decimal with a leading "0t" if it contains 8 digits or less; in hexadecimal with a leading "0x" if it is longer than 8 digits. (Consult the __-o__ '' o'' option description for information on when 8 might default to some other value.)
554 ;: Thus the leading "0t" and "0x" identify an offset when the column may contain both a size and an offset (i.e., its title is SIZE/OFF).
555 ;: If the __-o__ option is specified, ''lsof'' always displays the file offset (or nothing if no offset is available) and labels the column OFFSET. The offset always begins with "0t" or "0x" as described above.
556 ;: The ''lsof'' user can control the switch from "0t" to "0x" with the __-o__ '' o'' option. Consult its description for more information.
557 ;: If the __-s__ option is specified, ''lsof'' always displays the file size (or nothing if no size is available) and labels the column SIZE. The __-o__ and __-s__ options are mutually exclusive; they can't both be specified.
558 ;: For files that don't have a fixed size - e.g., don't reside on a disk device - ''lsof'' will display appropriate information about the current size or position of the file if it is available in the kernel structures that define the file.
559 ;NODE : is the node number of a local file;
560 ;: or the inode number of an NFS file in the server host;
561 ;: or the Internet protocol type - e. g, "TCP";
562 ;: or "STR" for a stream;
563 ;: or "CCITT" for an HP-UX x.25 socket;
564 ;: or the IRQ or inode number of a Linux AX.25 socket device.
565 ;NAME : is the name of the mount point and file system on which the file resides;
566 ;: or the name of a file specified in the ''names'' option (after any symbolic links have been resolved);
567 ;: or the name of a character special or block special device;
568 ;: or the local and remote Internet addresses of a network file; the local host name or IP number is followed by a colon (':'), the port, "->", and the two-part remote address; IP addresses may be reported as numbers or names, depending on the __+|-M__ , __-n__ , and __-P__ options; colon-separated IPv6 numbers are enclosed in square brackets; IPv4 INADDR_ANY and IPv6 IN6_IS_ADDR_UNSPECIFIED addresses are represented by an asterisk ('*'); a UDP destination address may be followed by the amount of time elapsed since the last packet was sent to the destination; TCP and UDP remote addresses may be followed by TCP/TPI information in parentheses - state (e.g., "(ESTABLISHED)", "(Unbound)"), queue sizes, and window sizes (not all dialects) - in a fashion similar to what netstat(1) reports; see the __-T__ option description or the description of the TCP/TPI field in __OUTPUT FOR OTHER PROGRAMS__ for more information on state, queue size, and window size;
569 ;: or the address or name of a UNIX domain socket, possibly including a stream clone device name, a file system object's path name, local and foreign kernel addresses, socket pair information, and a bound vnode address;
570 ;: or the local and remote mount point names of an NFS file;
571 ;: or "STR", followed by the stream name;
572 ;: or a stream character device name, followed by "->" and the stream name;
573 ;: or "STR:" followed by the SCO !OpenServer stream device and module names, separated by "->";
574 ;: or system directory name, " -- ", and as many components of the path name as ''lsof'' can find in the kernel's name cache for selected dialects (See the __KERNEL NAME CACHE__ section for more information.);
575 ;: or "PIPE->", followed by a Solaris kernel pipe destination address;
576 ;: or "COMMON:", followed by the vnode device information structure's device name, for a Solaris common vnode;
577 ;: or the address family, followed by a slash (`/'), followed by fourteen comma-separated bytes of a non-Internet raw socket address;
578 ;: or the HP-UX x.25 local address, followed by the virtual connection number (if any), followed by the remote address (if any);
579 ;: or "(dead)" for disassociated DEC OSF/1, Digital UNIX, or Tru64 UNIX files - typically terminal files that have been flagged with the TIOCNOTTY ioctl and closed by daemons;
580 ;: or "rd=<offset>" and "wr=<offset>" for the values of the read and write offsets of a FIFO;
581 ;: or "clone ''n'':/dev/event" for SCO !OpenServer file clones of the ''/dev/event'' device, where ''n'' is the minor device number of the file;
582 ;: or "(socketpair: n)" for a Solaris 2.6, 7, 8 BETA, or 8 BETA-Refresh UNIX domain socket, created by the socketpair(3N) network function;
583 ;: or "no PCB" for socket files that do not have a protocol block associated with them, optionally followed by ", CANTSENDMORE" if sending on the socket has been disabled, or ", CANTRCVMORE" if receiving on the socket has been disabled (e.g., by the shutdown(2) function);
584 ;: or the local and remote addresses of a Linux IPX socket file in the form <net>:[[<node>:]<port>, followed in parentheses by the transmit and receive queue sizes, and the connection state;
585 ;: or "dgram" or "stream" for the type !UnixWare 7.1.1 and above in-kernel UNIX domain sockets, followed by a colon (':') and the local path name when available, followed by "->" and the remote path name or kernel socket address in hexadecimal when available.
1 perry 586
3 CraigBox 587 For dialects that support a "namefs" file system, allowing one file to be attached to another with fattach(3C), ''lsof'' will add "(FA:<address1><direction><address2>)" to the NAME column. <address1> and <address2> are hexadecimal vnode addresses. <direction> will be "<-" if <address2> has been fattach'ed to this vnode whose address is <address1>; and "->" if <address1>, the vnode address of this vnode, has been fattach'ed to <address2>. <address1> may be omitted if it already appears in the DEVICE column.
1 perry 588
589 !!LOCKS
3 CraigBox 590 ''Lsof'' can't adequately report the wide variety of UNIX dialect file locks in a single character. What it reports in a single character is a compromise between the information it finds in the kernel and the limitations of the reporting format.
1 perry 591
3 CraigBox 592 Moreover, when a process holds several byte level locks on a file, ''lsof'' only reports the status of the first lock it encounters. If it is a byte level lock, then the lock character will be reported in lower case - i.e., `r', `w', or `x' - rather than the upper case equivalent reported for a full file lock.
1 perry 593
3 CraigBox 594 Generally ''lsof'' can only report on locks held by local processes on local files. When a local process sets a lock on a remotely mounted (e.g., NFS) file, the remote server host usually records the lock state. One exception is Solaris - at some patch levels of 2.3, and in all versions above 2.4, the Solaris kernel records information on remote locks in local structures.
1 perry 595
3 CraigBox 596 ''Lsof'' has trouble reporting locks for some UNIX dialects. Consult the __BUGS__ section of this manual page or the ''lsof'' FAQ (The __FAQ__ section gives its location.) for more information.
1 perry 597
598 !!OUTPUT FOR OTHER PROGRAMS
3 CraigBox 599 When the __-F__ option is specified, ''lsof'' produces output that is suitable for processing by another program - e.g, an ''awk'' or ''Perl'' script.
1 perry 600
3 CraigBox 601 Each unit of information is output in a field that is identified with a leading character and terminated by a NL (012) (or a NUL (000) if the 0 (zero) field identifier character is specified.) The data of the field follows immediately after the field identification character and extends to the field terminator.
1 perry 602
3 CraigBox 603 It is possible to think of field output as process and file sets. A process set begins with a field whose identifier is `p' (for process IDentifier (PID)). It extends to the beginning of the next PID field or the beginning of the first file set of the process, whichever comes first. Included in the process set are fields that identify the command, the process group IDentification (PGID) number, and the user ID (UID) number or login name.
1 perry 604
3 CraigBox 605 A file set begins with a field whose identifier is `f' (for file descriptor). It is followed by lines that describe the file's access mode, lock state, type, device, size, offset, inode, protocol, name and stream module names. It extends to the beginning of the next file or process set, whichever comes first.
1 perry 606
3 CraigBox 607 When the NUL (000) field terminator has been selected with the 0 (zero) field identifier character, ''lsof'' ends each process and file set with a NL (012) character.
1 perry 608
3 CraigBox 609 ''Lsof'' always produces one field, the PID (`p') field. All other fields may be declared optionally in the field identifier character list that follows the __-F__ option. When a field selection character identifies an item ''lsof'' does not normally list - e.g., PPID, selected with __-R__ - specification of the field character - e.g., "__-FR__" - also selects the listing of the item.
1 perry 610
3 CraigBox 611 It is entirely possible to select a set of fields that cannot easily be parsed - e.g., if the field descriptor field is not selected, it may be difficult to identify file sets. To help you avoid this difficulty, ''lsof'' supports the __-F__ option; it selects the output of all fields with NL terminators (the __-F0__ option pair selects the output of all fields with NUL terminators).
1 perry 612
3 CraigBox 613 These are the fields that ''lsof'' will produce. The single character listed first is the field identifier.
1 perry 614
615
3 CraigBox 616 a file access mode %%%
617 c process command name (all characters from proc or %%%
618 user structure) %%%
619 C file structure share count %%%
620 d file's device character code %%%
621 D file's major/minor device number (0x<hexadecimal>) %%%
622 f file descriptor %%%
623 F file structure address (0x<hexadecimal>) %%%
624 G file flaGs (0x<hexadecimal>; names if __+fg__ follows) %%%
625 i file's inode number %%%
626 l file's lock status %%%
627 L process login name %%%
628 m marker between repeated output %%%
629 n file name, comment, Internet address %%%
630 N node identifier (ox<hexadecimal> %%%
631 o file's offset (decimal) %%%
632 p process ID (always selected) %%%
633 g process group ID %%%
634 P protocol name %%%
635 R parent process ID %%%
636 s file's size (decimal) %%%
637 S file's stream identification %%%
638 t file's type %%%
639 T TCP/TPI information, identified by prefixes (the %%%
640 `=' is part of the prefix): %%%
641 ST=<state> %%%
642 QR=<read queue size> %%%
643 QS=<write queue size> %%%
644 WR=<window read size> (not all dialects) %%%
645 WW=<window write size> (not all dialects) %%%
646 (TPI state information and window sizes aren't %%%
647 reported for all supported UNIX dialects. The %%%
648 __-h__ or __-?__ help output for the __-T__ option will %%%
649 show whether window size reporting can be %%%
650 requested.) %%%
651 u process user ID %%%
652 0 use NUL field terminator character in place of NL %%%
653 1-\9 dialect-specific field identifiers (The output %%%
654 of __-F?__ identifies the information to be found %%%
655 in dialect-specific fields.) %%%
1 perry 656
657
658
659 You can get on-line help information on these characters and their descriptions by specifying the __-F?__ option pair. (Escape the `?' character as your shell requires.) Additional information on field content can be found in the __OUTPUT__ section.
660
3 CraigBox 661 As an example, "__-F pcfn__" will select the process ID (`p'), command name (`c'), file descriptor (`f') and file name (`n') fields with an NL field terminator character; "__-F pcfn0__" selects the same output with a NUL (000) field terminator character.
1 perry 662
3 CraigBox 663 ''Lsof'' doesn't produce all fields for every process or file set, only those that are available. Some fields are mutually exclusive: file device characters and file major/minor device numbers; file inode number and protocol name; file name and stream identification; file size and offset. One or the other member of these mutually exclusive sets will appear in field output, but not both.
1 perry 664
3 CraigBox 665 Normally ''lsof'' ends each field with a NL (012) character. The 0 (zero) field identifier character may be specified to change the field terminator character to a NUL (000). A NUL terminator may be easier to process with ''xargs (1),'' for example, or with programs whose quoting mechanisms may not easily cope with the range of characters in the field output. When the NUL field terminator is in use, ''lsof'' ends each process and file set with a NL (012).
1 perry 666
3 CraigBox 667 Two aids to producing programs that can process ''lsof'' field output are included in the ''lsof'' distribution. The first is a C header file, ''lsof_fields.h'' , that contains symbols for the field identification characters, indexes for storing them in a table, and explanation strings that may be compiled into programs. ''Lsof'' uses this header file.
1 perry 668
3 CraigBox 669 The second aid is a set of sample scripts that process field output, written in ''awk'' , ''Perl'' 4, and ''Perl'' 5. They're located in the ''scripts'' subdirectory of the ''lsof'' distribution.
1 perry 670
671 !!BLOCKS AND TIMEOUTS
3 CraigBox 672 ''Lsof'' can be blocked by some kernel functions that it uses - lstat(2), readlink(2), and stat(2). These functions are stalled in the kernel, for example, when the hosts where mounted NFS file systems reside become inaccessible.
1 perry 673
3 CraigBox 674 ''Lsof'' attempts to break these blocks with timers and child processes, but the techniques are not wholly reliable. When ''lsof'' does manage to break a block, it will report the break with an error message. The messages may be suppressed with the __-t__ and __-w__ options.
1 perry 675
3 CraigBox 676 The default timeout value may be displayed with the __-h__ or __-?__ option, and it may be changed with the __-S__ '' [[t]'' option. The minimum for ''t'' is two seconds, but you should avoid small values, since slow system responsiveness can cause short timeouts to expire unexpectedly and perhaps stop ''lsof'' before it can produce any output.
1 perry 677
3 CraigBox 678 When ''lsof'' has to break a block during its access of mounted file system information, it normally continues, although with less information available to display about open files.
1 perry 679
3 CraigBox 680 ''Lsof'' can also be directed to avoid the protection of timers and child processes when using the kernel functions that might block by specifying the __-O__ option. While this will allow ''lsof'' to start up with less overhead, it exposes ''lsof'' completely to the kernel situations that might block it. Use this option cautiously.
1 perry 681
3 CraigBox 682 !!AVOIDING KERNEL BLOCKS
1 perry 683
684
3 CraigBox 685 You can use the __-b__ option to tell ''lsof'' to avoid using kernel functions that would block. Some cautions apply.
1 perry 686
3 CraigBox 687 First, using this option usually requires that your system supply alternate device numbers in place of the device numbers that ''lsof'' would normally obtain with the lstat(2) and stat(2) kernel functions. See the __ALTERNATE DEVICE NUMBERS__ section for more information on alternate device numbers.
1 perry 688
3 CraigBox 689 Second, you can't specify ''names'' for ''lsof'' to locate unless they're file system names. This is because ''lsof'' needs to know the device and inode numbers of files listed with ''names'' in the ''lsof'' options, and the __-b__ option prevents ''lsof'' from obtaining them. Moreover, since ''lsof'' only has device numbers for the file systems that have alternates, its ability to locate files on file systems depends completely on the availability and accuracy of the alternates. If no alternates are available, or if they're incorrect, ''lsof'' won't be able to locate files on the named file systems.
1 perry 690
3 CraigBox 691 Third, if the names of your file system directories that ''lsof'' obtains from your system's mount table are symbolic links, ''lsof'' won't be able to resolve the links. This is because the __-b__ option causes ''lsof'' to avoid the kernel readlink(2) function it uses to resolve symbolic links.
1 perry 692
3 CraigBox 693 Finally, using the __-b__ option causes ''lsof'' to issue warning messages when it needs to use the kernel functions that the __-b__ option directs it to avoid. You can suppress these messages by specifying the __-w__ option, but if you do, you won't see the alternate device numbers reported in the warning messages.
1 perry 694
3 CraigBox 695 !!ALTERNATE DEVICE NUMBERS
1 perry 696
697
3 CraigBox 698 On some dialects, when ''lsof'' has to break a block because it can't get information about a mounted file system via the lstat(2) and stat(2) kernel functions, or because you specified the __-b__ option, ''lsof'' can obtain some of the information it needs - the device number and possibly the file system type - from the system mount table. When that is possible, ''lsof'' will report the device number it obtained. (You can suppress the report by specifying the __-w__ option.)
1 perry 699
3 CraigBox 700 You can assist this process if your mount table is supported with an ''/etc/mtab'' or ''/etc/mnttab'' file that contains an options field by adding a "dev=xxxx" field for mount points that do not have one in their options strings.
1 perry 701
3 CraigBox 702 The "xxxx" portion of the field is the hexadecimal value of the file system's device number. (Consult the ''st_dev'' field of the output of the lstat(2) and stat(2) functions for the appropriate values for your file systems.) Here's an example from a Sun Solaris 2.6 ''/etc/mnttab'' for a file system remotely mounted via NFS:
1 perry 703
704
3 CraigBox 705 nfs ignore,noquota,dev=2a40001 %%%
1 perry 706
707
708
3 CraigBox 709 There's an advantage to having "dev=xxxx" entries in your mount table file, especially for file systems that are mounted from remote NFS servers. When a remote server crashes and you want to identify its users by running ''lsof'' on one of its clients, ''lsof'' probably won't be able to get output from the lstat(2) and stat(2) functions for the file system. If it can obtain the file system's device number from the mount table, it will be able to display the files open on the crashed NFS server.
1 perry 710
3 CraigBox 711 Some dialects that do not use an ASCII ''/etc/mtab'' or ''/etc/mnttab'' file for the mount table may still provide an alternative device number in their internal mount tables. This includes AIX, Apple Darwin, DEC OSF/1, Digital UNIX, FreeBSD, NetBSD, OpenBSD, and Tru64 UNIX. ''Lsof'' knows how to obtain the alternative device number for these dialects and uses it when its attempt to lstat(2) or stat(2) the file system is blocked.
1 perry 712
3 CraigBox 713 If you're not sure your dialect supplies alternate device numbers for file systems from its mount table, use this ''lsof'' incantation to see if it reports any alternate device numbers:
1 perry 714
715
3 CraigBox 716 ;: lsof -b
1 perry 717
3 CraigBox 718 Look for standard error file warning messages that begin "assuming "dev=xxxx" from ...".
1 perry 719
3 CraigBox 720 !!KERNEL NAME CACHE
1 perry 721
722
3 CraigBox 723 ''Lsof'' is able to examine the kernel's name cache or use other kernel facilities (e.g., the ADVFS 4.x tag_to_path() function under Digital UNIX or Tru64 UNIX) on some dialects for most file system types, excluding AFS, and extract recently used path name components from it. (AFS file system path lookups don't use the kernel's name cache.)
1 perry 724
3 CraigBox 725 ''Lsof'' reports the complete paths it finds in the NAME column. If ''lsof'' can't report all components in a path, it reports in the NAME column the file system name, followed by a space, two `-' characters, another space, and the name components it has located, separated by the `/' character.
1 perry 726
3 CraigBox 727 When ''lsof'' is run in repeat mode - i.e., with the __-r__ option specified - the extent to which it can report path name components for the same file may vary from cycle to cycle. That's because other running processes can cause the kernel to remove entries from its name cache and replace them with others.
1 perry 728
3 CraigBox 729 ''Lsof's'' use of the kernel name cache to identify the paths of files can lead it to report incorrect components under some circumstances. This can happen when the kernel name cache uses device and node number as a key (e.g., Linux and SCO !OpenServer) and a key on a rapidly changing file system is reused. If the UNIX dialect's kernel doesn't purge the name cache entry for a file when it is unlinked, ''lsof'' may find a reference to the wrong entry in the cache. The ''lsof'' FAQ (The __FAQ__ section gives its location.) has more information on this situation.
1 perry 730
3 CraigBox 731 ''Lsof'' can report path name components for these dialects:
1 perry 732
733
3 CraigBox 734 BSDI BSD/OS %%%
735 DC/OSx %%%
736 DEC OSF/1, Digital UNIX, Tru64 UNIX %%%
737 FreeBSD %%%
738 HP-UX %%%
739 Linux %%%
740 NetBSD %%%
741 NEXTSTEP %%%
742 OpenBSD %%%
743 PTX %%%
744 Reliant UNIX %%%
745 SCO !OpenServer %%%
746 SCO !UnixWare %%%
747 Solaris %%%
748 Ultrix (no longer available) %%%
1 perry 749
750
751
3 CraigBox 752 ''Lsof'' can't report path name components for these dialects:
1 perry 753
754
3 CraigBox 755 AIX %%%
1 perry 756
757
758
3 CraigBox 759 If you want to know why ''lsof'' can't report path name components for some dialects, see the ''lsof'' FAQ (The __FAQ__ section gives its location.)
1 perry 760
3 CraigBox 761 !!DEVICE CACHE FILE
1 perry 762
763
3 CraigBox 764 Examining all members of the ''/dev'' (or ''/devices'' ) node tree with stat(2) functions can be time consuming. What's more, the information that ''lsof'' needs - device number, inode number, and path - rarely changes.
1 perry 765
3 CraigBox 766 Consequently, ''lsof'' normally maintains an ASCII text file of cached ''/dev'' (or ''/devices'' ) information (exception: the /proc-based Linux ''lsof'' where it's not needed.) The local system administrator who builds ''lsof'' can control the way the device cache file path is formed, selecting from these options:
1 perry 767
768
3 CraigBox 769 Path from the __-D__ option; %%%
770 Path from an environment variable; %%%
771 System-wide path; %%%
772 Personal path (the default); %%%
773 Personal path, modified by an environment variable. %%%
1 perry 774
775
776
3 CraigBox 777 Consult the output of the __-h__ , __-D? ,__ or __-?__ help options for the current state of device cache support. The help output lists the default read-mode device cache file path that is in effect for the current invocation of ''lsof'' . The __-D?__ option output lists the read-only and write device cache file paths, the names of any applicable environment variables, and the personal device cache path format.
1 perry 778
3 CraigBox 779 ''Lsof'' can detect that the current device cache file has been accidentally or maliciously modified by integrity checks, including the computation and verification of a sixteen bit Cyclic Redundancy Check (CRC) sum on the file's contents. When ''lsof'' senses something wrong with the file, it issues a warning and attempts to remove the current cache file and create a new copy, but only to a path that the process can legitimately write.
1 perry 780
3 CraigBox 781 The path from which a ''lsof'' process may attempt to read a device cache file may not be the same as the path to which it can legitimately write. Thus when ''lsof'' senses that it needs to update the device cache file, it may choose a different path for writing it from the path from which it read an incorrect or outdated version.
1 perry 782
3 CraigBox 783 If available, the __-Dr__ option will inhibit the writing of a new device cache file. (It's always available when specified without a path name argument.)
1 perry 784
3 CraigBox 785 When a new device is added to the system, the device cache file may need to be recreated. Since ''lsof'' compares the mtime of the device cache file with the mtime and ctime of the ''/dev'' (or ''/devices'' ) directory, it usually detects that a new device has been added; in that case ''lsof'' issues a warning message and attempts to rebuild the device cache file.
1 perry 786
3 CraigBox 787 Whenever ''lsof'' writes a device cache file, it sets its ownership to the real UID of the executing process, and its permission modes to 0600, this restricting its reading and writing to the file's owner.
1 perry 788
3 CraigBox 789 !!LSOF PERMISSIONS THAT AFFECT DEVICE CACHE FILE ACCESS
1 perry 790
791
3 CraigBox 792 Two permissions of the ''lsof'' executable affect its ability to access device cache files. The permissions are set by the local system administrator when ''lsof'' is installed.
1 perry 793
3 CraigBox 794 The first and rarer permission is setuid-root. It comes into effect when ''lsof'' is executed; its effective UID is then root, while its real (i.e., that of the logged-on user) UID is not. The ''lsof'' distribution recommends that versions for these dialects run setuid-root.
1 perry 795
796
3 CraigBox 797 DC/OSx 1.1 for Pyramid systems %%%
798 Reliant UNIX 5.4[[34] for Pyramid systems %%%
1 perry 799
800
801
3 CraigBox 802 The second and more common permission is setgid. It comes into effect when the effective group IDentification number (GID) of the ''lsof'' process is set to one that can access kernel memory devices - e.g., "kmem", "sys", or "system".
1 perry 803
3 CraigBox 804 An ''lsof'' process that has setgid permission usually surrenders the permission after it has accessed the kernel memory devices. When it does that, ''lsof'' can allow more liberal device cache path formations. The ''lsof'' distribution recommends that versions for these dialects run setgid and be allowed to surrender setgid permission.
1 perry 805
806
3 CraigBox 807 AIX 4.3.[[23], 5L, and 5.1 %%%
808 Apple Darwin 1.[[23] for Power Macintosh systems %%%
809 BSDI BSD/OS 4.1 for Intel-based systems %%%
810 DEC OSF/1, Digital UNIX, Tru64 UNIX 4.0, and 5.[[01] %%%
811 FreeBSD 4.[[23] and 5.0 for Intel-based systems %%%
812 HP-UX 11.00 %%%
813 NetBSD 1.5 for Alpha, Intel, and SPARC-based systems %%%
814 NEXTSTEP 3.[[13] for NEXTSTEP architectures %%%
815 OpenBSD 2.[[89] for Intel-based systems %%%
816 SCO !OpenServer Release 5.0.[[45] for Intel-based systems %%%
817 SCO !UnixWare 7.1.1 for Intel-based systems %%%
818 Sequent PTX 4.4.[[46], 4.5[[.1], and 4.6[[.1] %%%
819 Solaris 2.6, 7, 8, and 9 BETA %%%
1 perry 820
821
822
3 CraigBox 823 (Note: ''lsof'' for AIX 5L and above needs setuid-root permission if its __-X__ option is used.)
1 perry 824
3 CraigBox 825 ''Lsof'' for these dialects does not support a device cache, so the permissions given to the executable don't apply to the device cache file.
1 perry 826
827
3 CraigBox 828 Linux 2.1.72 and above (/proc-based ''lsof'') %%%
1 perry 829
830
831
832 !!DEVICE CACHE FILE PATH FROM THE -D OPTION
833
834
3 CraigBox 835 The __-D__ option provides limited means for specifying the device cache file path. Its __?__ function will report the read-only and write device cache file paths that ''lsof'' will use.
1 perry 836
3 CraigBox 837 When the __-D__ __b__ , __r__ , and __u__ functions are available, you can use them to request that the cache file be built in a specific location (__b__[[''path'']); read but not rebuilt (__r__[[''path'']); or read and rebuilt (__u__[[''path'']). The __b__ , __r__ , and __u__ functions are restricted under some conditions. They are restricted when the ''lsof'' process is setuid-root. The path specified with the __r__ function is always read-only, even when it is available.
1 perry 838
3 CraigBox 839 The __b__ , __r__ , and __u__ functions are also restricted when the ''lsof'' process runs setgid and ''lsof'' doesn't surrender the setgid permission. (See the __LSOF PERMISSIONS THAT AFFECT DEVICE CACHE FILE ACCESS__ section for a list of implementations that normally don't surrender their setgid permission.)
1 perry 840
3 CraigBox 841 A further __-D__ function, __i__ (for ignore), is always available.
1 perry 842
3 CraigBox 843 When available, the __b__ function tells ''lsof'' to read device information from the kernel with the stat(2) function and build a device cache file at the indicated path.
1 perry 844
3 CraigBox 845 When available, the __r__ function tells ''lsof'' to read the device cache file, but not update it. When a path argument accompanies __-Dr__ , it names the device cache file path. The __r__ function is always available when it is specified without a path name argument. If ''lsof'' is not running setuid-root and surrenders its setgid permission, a path name argument may accompany the __r__ function.
1 perry 846
3 CraigBox 847 When available, the __u__ function tells ''lsof'' to attempt to read and use the device cache file. If it can't read the file, or if it finds the contents of the file incorrect or outdated, it will read information from the kernel, and attempt to write an updated version of the device cache file, but only to a path it considers legitimate for the ''lsof'' process effective and real UIDs.
1 perry 848
849 !!DEVICE CACHE PATH FROM AN ENVIRONMENT VARIABLE
850
851
3 CraigBox 852 ''Lsof's'' second choice for the device cache file is the contents of the LSOFDEVCACHE environment variable. It avoids this choice if the ''lsof'' process is setuid-root, or the real UID of the process is root.
1 perry 853
3 CraigBox 854 A further restriction applies to a device cache file path taken from the LSOFDEVCACHE environment variable: ''lsof'' will not write a device cache file to the path if the ''lsof'' process doesn't surrender its setgid permission. (See the __LSOF PERMISSIONS THAT AFFECT DEVICE CACHE FILE ACCESS__ section for information on implementations that don't surrender their setgid permission.)
1 perry 855
3 CraigBox 856 The local system administrator can disable the use of the LSOFDEVCACHE environment variable or change its name when building ''lsof'' . Consult the output of __-D?__ for the environment variable's name.
1 perry 857
858 !!SYSTEM-WIDE DEVICE CACHE PATH
859
860
3 CraigBox 861 The local system administrator may choose to have a system-wide device cache file when building ''lsof'' . That file will generally be constructed by a special system administration procedure when the system is booted or when the contents of ''/dev'' or ''/devices'' ) changes. If defined, it is ''lsof's'' third device cache file path choice.
1 perry 862
3 CraigBox 863 You can tell that a system-wide device cache file is in effect for your local installation by examining the ''lsof'' help option output - i.e., the output from the __-h__ or __-?__ option.
1 perry 864
3 CraigBox 865 ''Lsof'' will never write to the system-wide device cache file path by default. It must be explicitly named with a __-D__ function in a root-owned procedure. Once the file has been written, the procedure must change its permission modes to 0644 (owner-read and owner-write, group-read, and other-read).
1 perry 866
867 !!PERSONAL DEVICE CACHE PATH (DEFAULT)
868
869
3 CraigBox 870 The default device cache file path of the ''lsof'' distribution is one recorded in the home directory of the real UID that executes ''lsof'' . Added to the home directory is a second path component of the form ''.lsof_hostname'' .
1 perry 871
3 CraigBox 872 This is ''lsof's'' fourth device cache file path choice, and is usually the default. If a system-wide device cache file path was defined when ''lsof'' was built, this fourth choice will be applied when ''lsof'' can't find the system-wide device cache file. This is the __only__ time ''lsof'' uses two paths when reading the device cache file.
1 perry 873
3 CraigBox 874 The ''hostname'' part of the second component is the base name of the executing host, as returned by gethostname(2). The base name is defined to be the characters preceding the first `.' in the gethostname(2) output, or all the gethostname(2) output if it contains no `.'.
1 perry 875
3 CraigBox 876 The device cache file belongs to the user ID and is readable and writable by the user ID alone - i.e., its modes are 0600. Each distinct real user ID on a given host that executes ''lsof'' has a distinct device cache file. The ''hostname'' part of the path distinguishes device cache files in an NFS-mounted home directory into which device cache files are written from several different hosts.
1 perry 877
3 CraigBox 878 The personal device cache file path formed by this method represents a device cache file that ''lsof'' will attempt to read, and will attempt to write should it not exist or should its contents be incorrect or outdated.
1 perry 879
3 CraigBox 880 The __-Dr__ option without a path name argument will inhibit the writing of a new device cache file.
1 perry 881
3 CraigBox 882 The __-D?__ option will list the format specification for constructing the personal device cache file. The conversions used in the format specification are described in the ''00DCACHE'' file of the ''lsof'' distribution.
1 perry 883
3 CraigBox 884 !!MODIFIED PERSONAL DEVICE CACHE PATH
1 perry 885
886
3 CraigBox 887 If this option is defined by the local system administrator when ''lsof'' is built, the LSOFPERSDCPATH environment variable contents may be used to add a component of the personal device cache file path.
1 perry 888
3 CraigBox 889 The LSOFPERSDCPATH variable contents are inserted in the path at the place marked by the local system administrator with the "%p" conversion in the HASPERSDC format specification of the dialect's ''machine.h '' header file. (It's placed right after the home directory in the default ''lsof'' distribution.)
1 perry 890
3 CraigBox 891 Thus, for example, if LSOFPERSDCPATH contains "LSOF", the home directory is "/Homes/abe", the host name is "vic.cc.purdue.edu", and the HASPERSDC format is the default ("%h/%p.lsof_%L"), the modified personal device cache file path is:
1 perry 892
893
3 CraigBox 894 /Homes/abe/LSOF/.lsof_vic %%%
1 perry 895
896
897
898 The LSOFPERSDCPATH environment variable is ignored when the ''lsof'' process is setuid-root or when the real UID of the process is root.
899
3 CraigBox 900 ''Lsof'' will not write to a modified personal device cache file path if the ''lsof'' process doesn't surrender setgid permission. (See the __LSOF PERMISSIONS THAT AFFECT DEVICE CACHE FILE ACCESS__ section for a list of implementations that normally don't surrender their setgid permission.)
1 perry 901
3 CraigBox 902 If, for example, you want to create a sub-directory of personal device cache file paths by using the LSOFPERSDCPATH environment variable to name it, and ''lsof'' doesn't surrender its setgid permission, you will have to allow ''lsof'' to create device cache files at the standard personal path and move them to your subdirectory with shell commands.
1 perry 903
3 CraigBox 904 The local system administrator may: disable this option when ''lsof'' is built; change the name of the environment variable from LSOFPERSDCPATH to something else; change the HASPERSDC format to include the personal path component in another place; or exclude the personal path component entirely. Consult the output of the __-D?__ option for the environment variable's name and the HASPERSDC format specification.
1 perry 905
906 !!DIAGNOSTICS
3 CraigBox 907 Errors are identified with messages on the standard error file.
1 perry 908
3 CraigBox 909 ''Lsof'' returns a one (1) if any error was detected, including the failure to locate command names, file names, Internet addresses or files, login names, NFS files, PIDs, PGIDs, or UIDs it was asked to list. If the __-V__ option is specified, ''lsof'' will indicate the search items it failed to list.
1 perry 910
3 CraigBox 911 It returns a zero (0) if no errors were detected and if it was able to list some information about all the specified search arguments.
1 perry 912
913
914
3 CraigBox 915 When ''lsof'' cannot open access to ''/dev'' (or ''/devices'' ) or one of its subdirectories, or get information on a file in them with stat(2), it issues a warning message and continues. That ''lsof'' will issue warning messages about inaccessible files in ''/dev'' (or ''/devices'' ) is indicated in its help output - requested with the __-h__ or >B -? options - with the message:
1 perry 916
917
3 CraigBox 918 Inaccessible /dev warnings are enabled. %%%
1 perry 919
920
921
922 The warning message may be suppressed with the __-w__ option. It may also have been suppressed by the system administrator when ''lsof'' was compiled by the setting of the WARNDEVACCESS definition. In this case, the output from the help options will include the message:
923
924
3 CraigBox 925 Inaccessible /dev warnings are disabled. %%%
1 perry 926
927
928
3 CraigBox 929 Inaccessible device warning messages usually disappear after ''lsof'' has created a working device cache file.
930
931 !!EXAMPLES
932 For a more extensive set of examples, documented more fully, see the ''00QUICKSTART'' file of the ''lsof'' distribution.
1 perry 933
934 To list all open files, use:
3 CraigBox 935 ;: lsof
1 perry 936
3 CraigBox 937 To list all open Internet, x.25 (HP-UX), and UNIX domain files, use:
938 ;: lsof -i -U
1 perry 939
3 CraigBox 940 To list all files using any protocol on ports 513, 514, or 515 of host wonderland.cc.purdue.edu, use:
941 ;: lsof -i @wonderland.cc.purdue.edu:513-515
1 perry 942
3 CraigBox 943 To list all files using any protocol on any port of mace.cc.purdue.edu (cc.purdue.edu is the default domain), use:
944 ;: lsof -i @mace
1 perry 945
3 CraigBox 946 To list all open files for login name "abe", or user ID 1234, or process 456, or process 123, or process 789, use:
947 ;: lsof -p 456,123,789 -u 1234,abe
1 perry 948
949 To list all open files on device /dev/hd4, use:
3 CraigBox 950 ;: lsof /dev/hd4
1 perry 951
3 CraigBox 952 To find the process that has /u/abe/foo open, use:
953 ;: lsof /u/abe/foo
1 perry 954
3 CraigBox 955 To send a SIGHUP to the processes that have /u/abe/bar open, use:
956 ;: kill -HUP `lsof -t /u/abe/bar`
1 perry 957
3 CraigBox 958 To find any open file, including an open UNIX domain socket file, with the name ''/dev/log'' , use:
959 ;: lsof /dev/log
1 perry 960
3 CraigBox 961 To find processes with open files on the NFS file system named ''/nfs/mount/point'' whose server is inaccessible, and presuming your mount table supplies the device number for ''/nfs/mount/point'' , use:
962 ;: lsof -b /nfs/mount/point
1 perry 963
3 CraigBox 964 To do the preceding search with warning messages suppressed, use:
965 ;: lsof -bw /nfs/mount/point
1 perry 966
967 To ignore the device cache file, use:
3 CraigBox 968 ;: lsof -Di
1 perry 969
3 CraigBox 970 To obtain PID and command name field output for each process, file descriptor, file device number, and file inode number for each file of each process, use:
971 ;: lsof -!FpcfDi
1 perry 972
3 CraigBox 973 To list the files at descriptors 1 and 3 of every process running the ''lsof'' command for login ID "abe" every 10 seconds, use:
974 ;: lsof -c lsof -a -d 1 -d 3 -u abe -r10
1 perry 975
3 CraigBox 976 To list the current working directory of processes running a command that is exactly four characters long and has an 'o' or 'O' in character three, use this regular expression form of the __-c__ '' c'' option:
977 ;: lsof -c /^..o.$/i -a -d cwd
1 perry 978
3 CraigBox 979 To find an IP version 4 socket file by its associated numeric dot-form address, use:
980 ;: lsof -i@128.210.15.17
1 perry 981
3 CraigBox 982 To find an IP version 6 socket file (when the UNIX dialect supports IPv6) by its associated numeric colon-form address, use:
983 ;: lsof -i@[[0:1:2:3:4:5:6:7]
1 perry 984
3 CraigBox 985 To find an IP version 6 socket file (when the UNIX dialect supports IPv6) by an associated numeric colon-form address that has a run of zeroes in it - e.g., the loop-back address - use:
986 ;: lsof -i@[[::1]
1 perry 987
988 !!BUGS
3 CraigBox 989 Since ''lsof'' reads kernel memory in its search for open files, rapid changes in kernel memory may produce unpredictable results.
1 perry 990
3 CraigBox 991 When a file has multiple record locks, the lock status character (following the file descriptor) is derived from a test of the first lock structure, not from any combination of the individual record locks that might be described by multiple lock structures.
1 perry 992
3 CraigBox 993 ''Lsof'' can't search for files with restrictive access permissions by ''name'' unless it is installed with root set-UID permission. Otherwise it is limited to searching for files to which its user or its set-GID group (if any) has access permission.
1 perry 994
3 CraigBox 995 The display of the destination address of a raw socket (e.g., for ''ping'' ) depends on the UNIX operating system. Some dialects store the destination address in the raw socket's protocol control block, some do not.
1 perry 996
3 CraigBox 997 ''Lsof'' can't always represent Solaris device numbers in the same way that ls(1) does. For example, the major and minor device numbers that the lstat(2) and stat(2) functions report for the directory on which CD-ROM files are mounted (typically ''/cdrom'' ) are not the same as the ones that it reports for the device on which CD-ROM files are mounted (typically ''/dev/sr0'' ). (''Lsof'' reports the directory numbers.)
1 perry 998
3 CraigBox 999 The support for ''/proc'' file systems is available only for BSD, DEC OSF/1, Digital UNIX, and Tru64 UNIX dialects, Linux, and dialects derived from SYSV R4 - e.g., FreeBSD, NetBSD, OpenBSD, Solaris, !UnixWare.
1 perry 1000
3 CraigBox 1001 Some ''/proc'' file items - device number, inode number, and file size - are unavailable in some dialects. Searching for files in a ''/proc'' file system may require that the full path name be specified.
1 perry 1002
3 CraigBox 1003 No text (__txt__) file descriptors are displayed for Linux processes. All entries for files other than the current working directory, the root directory, and numerical file descriptors are labeled __mem__ descriptors.
1 perry 1004
3 CraigBox 1005 ''Lsof'' can't search for DEC OSF/1, Digital UNIX, and Tru64 UNIX named pipes by name, because their kernel implementation of lstat(2) returns an improper device number for a named pipe.
1 perry 1006
3 CraigBox 1007 ''Lsof'' can't report fully or correctly on HP-UX 9.01, 10.20, and 11.00 locks because of insufficient access to kernel data or errors in the kernel data. See the ''lsof'' FAQ (The __FAQ__ section gives its location.) for details.
1 perry 1008
3 CraigBox 1009 The AIX SMT file type is a fabrication. It's made up for file structures whose type (15) isn't defined in the AIX ''/usr/include/sys/file.h'' header file. One way to create such file structures is to run X clients with the DISPLAY variable set to ":0.0".
1 perry 1010
3 CraigBox 1011 The __+|-f__ ''[[cfgGn]'' option is not supported under /proc-based Linux ''lsof'' , because it doesn't read kernel structures from kernel memory.
1 perry 1012
1013 !!ENVIRONMENT
3 CraigBox 1014 ''Lsof'' may access these environment variables.
1015 ;LSOFDEVCACHE : defines the path to a device cache file. See the __DEVICE CACHE PATH FROM AN ENVIRONMENT VARIABLE__ section for more information.
1016 ;LSOFPERSDCPATH : defines the middle component of a modified personal device cache file path. See the __MODIFIED PERSONAL DEVICE CACHE PATH__ section for more information.
1 perry 1017
3 CraigBox 1018 !!FAQ
1019 Frequently-asked questions and their answers (an FAQ) are available in the ''00FAQ'' file of the ''lsof'' distribution.
1 perry 1020
3 CraigBox 1021 That file is also available via anonymous ftp from ''vic.cc.purdue.edu'' at ''pub/tools/unix/lsof'' FAQ ''.'' The URL is:
1022 ;: ftp://vic.cc.purdue.edu/pub/tools/unix/lsof/FAQ
1 perry 1023
1024 !!FILES
1025
3 CraigBox 1026 ;''/dev/kmem'' : kernel virtual memory device
1027 ;''/dev/mem'' : physical memory device
1028 ;''/dev/swap'' : system paging device
1029 ;''.lsof_hostname'' : ''lsof's'' device cache file (The suffix, ''hostname'' , is the first component of the host's name returned by gethostname(2) ''.)''
1 perry 1030
1031 !!AUTHORS
3 CraigBox 1032 ''Lsof'' was written by Victor A. Abell <abe@purdue.edu> of the Purdue University Computing Center (PUCC). Many others have contributed to ''lsof'' . They're listed in the ''00CREDITS'' file of the ''lsof'' distribution.
1 perry 1033
1034 !!DISTRIBUTION
3 CraigBox 1035 The latest distribution of ''lsof'' is available via anonymous ftp from the host ''vic.cc.purdue.edu'' . You'll find the ''lsof'' distribution in the ''pub/tools/unix/lsof'' directory.
1 perry 1036
3 CraigBox 1037 You can also use this URL:
1038 ;: ftp://vic.cc.purdue.edu/pub/tools/unix/lsof
1 perry 1039
3 CraigBox 1040 ''Lsof'' is also mirrored elsewhere. When you access ''vic.cc.purdue.edu'' and change to its ''pub/tools/unix/lsof'' directory, you'll be given a list of some mirror sites. The ''pub/tools/unix/lsof'' directory also contains a more complete list in its ''mirrors'' file. Use mirrors with caution - not all mirrors always have the latest ''lsof'' revision.
1 perry 1041
3 CraigBox 1042 Some pre-compiled ''Lsof'' executables are available on ''vic.cc.purdue.edu'' , but their use is discouraged - it's better that you build your own from the sources. If you feel you must use a pre-compiled executable, please read the cautions that appear in the README files of the ''pub/tools/unix/lsof/binaries'' subdirectories and in the 00* files of the distribution.
1 perry 1043
3 CraigBox 1044 More information on the ''lsof'' distribution can be found in its ''README.lsof_<version>'' file. If you intend to get the ''lsof'' distribution and build it, please read ''README.lsof_<version>'' and the other 00* files of the distribution before sending questions to the author.
1 perry 1045
1046 !!SEE ALSO
1047
1048
3 CraigBox 1049 ''Lsof'' versions 2 and 3 have been tested under older UNIX dialects. They are available via anonymous ftp from ''vic.cc.purdue.edu'' in the ''pub/tools/unix/lsof/OLD'' directory.
1 perry 1050
3 CraigBox 1051 access(2), awk(1), crash(1), fattach(3C), ff(1), fstat(8), fuser(1), gethostname(2), isprint(3), kill(1), lstat(2), modload(8), mount(8), netstat(1), ofiles(8L), perl(1), ps(1), readlink(2), stat(2), uname(1).
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.

PHP Warning

lib/blame.php:177: Warning: Invalid argument supplied for foreach() (...repeated 55 times)