Goals:
!curl http://histo.ucsf.edu/BMS270/BMS270_2018/code/cdt_reader.py > cdt_reader.py
% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 3360 100 3360 0 0 100k 0 --:--:-- --:--:-- --:--:-- 102k
!ls *.py
cdt_reader.py stats.py
import cdt_reader
(colnames,genes,annotations,data) = cdt_reader.parse_cdt("supp2data.cdt")
(colnames,genes,annotations,data2) = cdt_reader.parse_cdt("supp2data.cdt",0.)
data[0][:10]
[None, None, 0.33, -0.17, 0.04, -0.07, -0.09, -0.12, -0.03, -0.2]
data2[0][:10]
[0.0, 0.0, 0.33, -0.17, 0.04, -0.07, -0.09, -0.12, -0.03, -0.2]
import cdt_reader
(colnames,genes,annotations,data) = cdt_reader.parse_cdt("supp2data.cdt")
data[0][:10]
[None, None, 0.33, -0.17, 0.04, -0.07, -0.09, -0.12, -0.03, -0.2]
import importlib
importlib.reload(cdt_reader)
(colnames,genes,annotations,data) = cdt_reader.parse_cdt("supp2data.cdt")
data[0][:10]
--------------------------------------------------------------------------- ValueError Traceback (most recent call last) /home/bms270/BMS270_2018/cdt_reader.py in parse_cdt(filename, null_value) 56 try: ---> 57 row_data.append(float(field)) 58 except ValueError: ValueError: could not convert string to float: 'YBR166C' During handling of the above exception, another exception occurred: AssertionError Traceback (most recent call last) <ipython-input-15-5afbb7cdbfed> in <module>() 1 importlib.reload(cdt_reader) ----> 2 (colnames,genes,annotations,data) = cdt_reader.parse_cdt("supp2data.cdt") 3 data[0][:10] /home/bms270/BMS270_2018/cdt_reader.py in parse_cdt(filename, null_value) 57 row_data.append(float(field)) 58 except ValueError: ---> 59 assert(field == "") 60 row_data.append(null_value) 61 AssertionError:
importlib.reload(cdt_reader)
(colnames,genes,annotations,data) = cdt_reader.parse_cdt("supp2data.cdt")
data[0][:10]
[0.33, -0.17, 0.04, -0.07, -0.09, -0.12, -0.03, -0.2, -0.06, -0.06]
dir()
['In', 'Out', '_', '_10', '_11', '_12', '_16', '_3', '__', '___', '__builtin__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__', '_dh', '_exit_code', '_i', '_i1', '_i10', '_i11', '_i12', '_i13', '_i14', '_i15', '_i16', '_i17', '_i2', '_i3', '_i4', '_i5', '_i6', '_i7', '_i8', '_i9', '_ih', '_ii', '_iii', '_oh', '_sh', 'annotations', 'cdt_reader', 'colnames', 'data', 'data2', 'exit', 'genes', 'get_ipython', 'importlib', 'quit', 'urllib']
%who
annotations cdt_reader colnames data data2 genes importlib urllib
!man lsof
LSOF(8) System Manager's Manual LSOF(8) NNAAMMEE lsof - list open files SSYYNNOOPPSSIISS llssooff [ --??aabbCChhKKllnnNNOOPPRRttUUvvVVXX ] [ --AA _A ] [ --cc _c ] [ ++cc _c ] [ ++||--dd _d ] [ ++||--DD _D ] [ ++||--ee _s ] [ ++||--EE ] [ ++||--ff [[ccffggGGnn]] ] [ --FF _[_f_] ] [ --gg _[_s_] ] [ --ii _[_i_] ] [ --kk _k ] [ ++||--LL _[_l_] ] [ ++||--mm _m ] [ ++||--MM ] [ --oo _[_o_] ] [ --pp _s ] [ ++||--rr _[_t_[_m_<_f_m_t_>_]_] ] [ --ss _[_p_:_s_] ] [ --SS _[_t_] ] [ --TT _[_t_] ] [ --uu _s ] [ ++||--ww ] [ --xx _[_f_l_] ] [ --zz _[_z_] ] [ --ZZ _[_Z_] ] [ ---- ] [_n_a_m_e_s] DDEESSCCRRIIPPTTIIOONN _L_s_o_f revision 4.89 lists on its standard output file information about files opened by processes for the following UNIX dialects: Apple Darwin 9 and Mac OS X 10.[567] FreeBSD 8.[234], 9.0, 10.0 and 11.0 for AMD64-based systems Linux 2.1.72 and above for x86-based systems Solaris 9, 10 and 11 (See the DDIISSTTRRIIBBUUTTIIOONN section of this manual page for information on how to obtain the latest _l_s_o_f revision.) 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. Instead of a formatted display, _l_s_o_f will produce output that can be parsed by other programs. See the --FF, option description, and the OOUUTT‐‐ PPUUTT FFOORR OOTTHHEERR PPRROOGGRRAAMMSS section for more information. In addition to producing a single output list, _l_s_o_f 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 ++||--rr _[_t_[_m_<_f_m_t_>_]_] option description for more information. OOPPTTIIOONNSS In the absence of any options, _l_s_o_f lists all open files belonging to all active processes. If any list request option is specified, other list requests must be specifically requested - e.g., if --UU is specified for the listing of UNIX socket files, NFS files won't be listed unless --NN is also speci‐ fied; or if a user list is specified with the --uu option, UNIX domain socket files, belonging to users not in the list, won't be listed unless the --UU option is also specified. Normally list options that are specifically stated are ORed - i.e., specifying the --ii option without an address and the --uufoo option pro‐ duces a listing of all network files OR files belonging to processes owned by user ``foo''. The exceptions are: 1) the `^' (negated) login name or user ID (UID), specified with the --uu option; 2) the `^' (negated) process ID (PID), specified with the --pp option; 3) the `^' (negated) process group ID (PGID), specified with the --gg option; 4) the `^' (negated) command, specified with the --cc option; 5) the (`^') negated TCP or UDP protocol state names, specified with the --ss _[_p_:_s_] option. Since they represent exclusions, they are applied without ORing or AND‐ ing and take effect before any other selection criteria are applied. The --aa option may be used to AND the selections. For example, specify‐ ing --aa, --UU, and --uufoo produces a listing of only UNIX socket files that belong to processes owned by user ``foo''. Caution: the --aa 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 accept‐ able. Wherever --aa is placed, it causes the ANDing of all selection options. Items of the same selection set - command names, file descriptors, net‐ work addresses, process identifiers, user identifiers, zone names, security contexts - are joined in a single ORed set and applied before the result participates in ANDing. Thus, for example, specifying --ii@aaa.bbb, --ii@ccc.ddd, --aa, and --uufff,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. Options may be grouped together following a single prefix -- e.g., the option set ``--aa --bb --CC'' may be stated as --aabbCC. However, since values are optional following ++||--ff, --FF, --gg, --ii, ++||--LL, --oo, ++||--rr, --ss, --SS, --TT, --xx and --zz. when you have no values for them be careful that the following character isn't ambiguous. For example, --FFnn might represent the --FF and --nn options, or it might represent the nn field identifier character fol‐ lowing the --FF option. When ambiguity is possible, start a new option with a `-' character - e.g., ``--FF --nn''. If the next option is a file name, follow the possibly ambiguous option with ``--'' - e.g., ``--FF ---- _n_a_m_e''. 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., --ii - 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., ++||--MM; ``-iM'' is not the same request as ``-i +M''. When in doubt, use separate options with appropriate prefixes. --?? --hh These two equivalent options select a usage (help) output list. _L_s_o_f 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.) --aa causes list selection options to be ANDed, as described above. --AA _A is available on systems configured for AFS whose AFS kernel code is implemented via dynamic modules. It allows the _l_s_o_f user to specify _A as an alternate name list file where the kernel addresses of the dynamic modules might be found. See the _l_s_o_f FAQ (The FFAAQQ section gives its location.) for more information about dynamic modules, their symbols, and how they affect _l_s_o_f. --bb causes _l_s_o_f to avoid kernel functions that might block - _l_s_t_a_t(2), _r_e_a_d_l_i_n_k(2), and _s_t_a_t(2). See the BBLLOOCCKKSS AANNDD TTIIMMEEOOUUTTSS and AAVVOOIIDDIINNGG KKEERRNNEELL BBLLOOCCKKSS sec‐ tions for information on using this option. --cc _c selects the listing of files for processes executing the com‐ mand that begins with the characters of _c. Multiple commands may be specified, using multiple --cc options. They are joined in a single ORed set before participating in AND option selec‐ tion. If _c begins with a `^', then the following characters specify a command name whose processes are to be ignored (excluded.) If _c begins and ends with a slash ('/'), the characters between the slashes are interpreted as a regular expression. Shell meta-characters in the regular expression must be quoted to prevent their interpretation by the shell. The closing slash may be followed by these modifiers: b the regular expression is a basic one. i ignore the case of letters. x the regular expression is an extended one (default). See the _l_s_o_f FAQ (The FFAAQQ section gives its location.) for more information on basic and extended regular expressions. 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 --VV option is specified. ++cc _w defines the maximum number of initial characters of the name, supplied by the UNIX dialect, of the UNIX command associated with a process to be printed in the COMMAND column. (The _l_s_o_f default is nine.) Note that many UNIX dialects do not supply all command name characters to _l_s_o_f in the files and structures from which _l_s_o_f obtains command name. Often dialects limit the number of characters supplied in those sources. For example, Linux 2.4.27 and Solaris 9 both limit command name length to 16 characters. If _w is zero ('0'), all command characters supplied to _l_s_o_f by the UNIX dialect will be printed. If _w is less than the length of the column title, ``COMMAND'', it will be raised to that length. --CC disables the reporting of any path name components from the kernel's name cache. See the KKEERRNNEELL NNAAMMEE CCAACCHHEE section for more information. ++dd _s causes _l_s_o_f to search for all open instances of directory _s and the files and directories it contains at its top level. ++dd does NOT descend the directory tree, rooted at _s. The ++DD _D option may be used to request a full-descent directory tree search, rooted at directory _D. Processing of the ++dd option does not follow symbolic links within _s unless the --xx or --xx ll option is also specified. Nor does it search for open files on file system mount points on subdirectories of _s unless the --xx or --xx ff option is also specified. 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 _s_t_a_t(2) function. --dd _s specifies a list of file descriptors (FDs) to exclude from or include in the output listing. The file descriptors are spec‐ ified in the comma-separated set _s - e.g., ``cwd,1,3'', ``^6,^2''. (There should be no spaces in the set.) The list is an exclusion list if all entries of the set begin with `^'. It is an inclusion list if no entry begins with `^'. Mixed lists are not permitted. A file descriptor number range may be in the set as long as neither member is empty, both members are numbers, and the ending member is larger than the starting one - e.g., ``0-7'' or ``3-10''. Ranges may be specified for exclusion if they have the `^' prefix - e.g., ``^0-7'' excludes all file descriptors 0 through 7. Multiple file descriptor numbers are joined in a single ORed set before participating in AND option selection. When there are exclusion and inclusion members in the set, _l_s_o_f reports them as errors and exits with a non-zero return code. See the description of File Descriptor (FD) output values in the OOUUTTPPUUTT section for more information on file descriptor names. ++DD _D causes _l_s_o_f to search for all open instances of directory _D and all the files and directories it contains to its complete depth. Processing of the ++DD option does not follow symbolic links within _D unless the --xx or --xx ll option is also specified. Nor does it search for open files on file system mount points on subdirectories of _D unless the --xx or --xx ff option is also specified. 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 _s_t_a_t(2) function. Further note: _l_s_o_f 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 _s_t_a_t(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. --DD _D directs _l_s_o_f_'_s use of the device cache file. The use of this option is sometimes restricted. See the DDEEVVIICCEE CCAACCHHEE FFIILLEE section and the sections that follow it for more information on this option. --DD must be followed by a function letter; the function letter may optionally be followed by a path name. _L_s_o_f recognizes these function letters: ?? - report device cache file paths bb - build the device cache file ii - ignore the device cache file rr - read the device cache file uu - read and update the device cache file The bb, rr, and uu functions, accompanied by a path name, are sometimes restricted. When these functions are restricted, they will not appear in the description of the --DD option that accompanies --hh or --?? option output. See the DDEEVVIICCEE CCAACCHHEE FFIILLEE section and the sections that follow it for more informa‐ tion on these functions and when they're restricted. The ?? function reports the read-only and write paths that lsof can use for the device cache file, the names of any envi‐ ronment variables whose values _l_s_o_f 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.) When available, the bb, rr, and uu functions may be followed by the device cache file's path. The standard default is _._l_s_o_f___h_o_s_t_n_a_m_e in the home directory of the real user ID that executes _l_s_o_f, but this could have been changed when _l_s_o_f was configured and compiled. (The output of the --hh and --?? options show the current default prefix - e.g., ``.lsof''.) The suffix, _h_o_s_t_n_a_m_e, is the first component of the host's name returned by _g_e_t_h_o_s_t_n_a_m_e(2). When available, the bb function directs _l_s_o_f to build a new device cache file at the default or specified path. The ii function directs _l_s_o_f to ignore the default device cache file and obtain its information about devices via direct calls to the kernel. The rr function directs _l_s_o_f 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 rr function, when specified without a path name, prevents _l_s_o_f from updating an incorrect or out‐ dated device cache file, or creating a new one in its place. The rr function is always available when it is specified with‐ out a path name argument; it may be restricted by the permis‐ sions of the _l_s_o_f process. When available, the uu function directs _l_s_o_f 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 --DD option has been specified. ++||--ee _s exempts the file system whose path name is _s from being sub‐ jected to kernel function calls that might block. The ++ee option exempts _s_t_a_t(2), _l_s_t_a_t(2) and most _r_e_a_d_l_i_n_k(2) kernel function calls. The --ee option exempts only _s_t_a_t_(_2_) and _l_s_t_a_t(2) kernel function calls. Multiple file systems may be specified with separate ++||--ee specifications and each may have _r_e_a_d_l_i_n_k(2) calls exempted or not. This option is currently implemented only for Linux. CCAAUUTTIIOONN:: this option can easily be mis-applied to other than the file system of interest, because it uses path name rather than the more reliable device and inode numbers. (Device and inode numbers are acquired via the potentially blocking _s_t_a_t(2) kernel call and are thus not available, but see the ++||--mm _m option as a possible alternative way to supply device numbers.) UUssee tthhiiss ooppttiioonn wwiitthh ggrreeaatt ccaarree aanndd ffuullllyy ssppeecciiffyy tthhee ppaatthh nnaammee ooff tthhee ffiillee ssyysstteemm ttoo bbee eexxeemmpptteedd.. When open files on exempted file systems are reported, it may not be possible to obtain all their information. Therefore, some information columns will be blank, the characters ``UNKN'' preface the values in the TYPE column, and the appli‐ cable exemption option is added in parentheses to the end of the NAME column. (Some device number information might be made available via the ++||--mm _m option.) ++||--EE ++EE specifies that Linux pipe and Linux UNIX socket files should be displayed with endpoint information and the files of the endpoints should also be displayed. Note: UNIX socket file endpoint information is available only when the compile flags line of --vv output contains HASUXSOCKEPT. Pipe endpoint information is displayed in the NAME column in the form ``_P_I_D_,_c_m_d_,_F_D_m_o_d_e'', where _P_I_D is the endpoint process ID; _c_m_d is the endpoint process command; _F_D is the endpoint file's descriptor; and _m_o_d_e is the endpoint file's access mode. UNIX socket file endpoint information is displayed in the NAME column in the form ``type=_T_Y_P_E ->INO=_I_N_O_D_E _P_I_D_,_c_m_d_,_F_D_m_o_d_e'', where _T_Y_P_E is the socket type; _I_N_O_D_E is the i-node number of the connected socket; and _P_I_D_, _c_m_d_, _F_D_, and _m_o_d_e are the same as with pipe endpoint information. Note: UNIX socket file endpoint infor‐ mation is available only when the compile flags line of --vv output contains HASUXSOCKEPT. Multiple occurrences of this information can appear in a file's NAME column. --EE specfies that Linux pipe and Linux UNIX socket files should be displayed with endpoint information, but not the files of the endpoints. ++||--ff [[ccffggGGnn]] ff by itself clarifies how path name arguments are to be inter‐ preted. When followed by cc, ff, gg, GG, or nn in any combination it specifies that the listing of kernel file structure infor‐ mation is to be enabled (`+') or inhibited (`-'). Normally a path name argument is taken to be a file system name if it matches a mounted-on directory name reported by _m_o_u_n_t(8), or if it represents a block device, named in the _m_o_u_n_t output and associated with a mounted directory name. When ++ff is specified, all path name arguments will be taken to be file system names, and _l_s_o_f 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. When --ff is specified by itself, all path name arguments will be taken to be simple files. Thus, for example, the ``--ff -- /'' arguments direct lsof to search for open files with a `/' path name, not all open files in the `/' (root) file system. Be careful to make sure ++ff and --ff are properly terminated and aren't followed by a character (e.g., of the file or file sys‐ tem name) that might be taken as a parameter. For example, use ``--'' after ++ff and --ff as in these examples. $ lsof +f -- /file/system/name $ lsof -f -- /file/name The listing of information from kernel file structures, requested with the ++ff [[ccffggGGnn]] option form, is normally inhib‐ ited, and is not available in whole or part for some dialects - e.g., /proc-based Linux kernels below 2.6.22. When the pre‐ fix to ff is a plus sign (`+'), these characters request file structure information: cc file structure use count (not Linux) ff file structure address (not Linux) gg file flag abbreviations (Linux 2.6.22 and up) GG file flags in hexadecimal (Linux 2.6.22 and up) nn file structure node address (not Linux) When the prefix is minus (`-') the same characters disable the listing of the indicated values. 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. _L_s_o_f column output can be sorted by out‐ put columns holding the values and listed to identify identi‐ cal file use, or _l_s_o_f field output can be parsed by an AWK or Perl post-filter script, or by a C program. --FF _f 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 OOUUTT‐‐ PPUUTT FFOORR OOTTHHEERR PPRROOGGRRAAMMSS section for a description of the field identification characters and the field output process. When the field selection character list is empty, all standard fields are selected (except the raw device field, security context and zone field for compatibility reasons) and the NL field terminator is used. When the field selection character list contains only a zero (`0'), all fields are selected (except the raw device field for compatibility reasons) and the NUL terminator character is used. Other combinations of fields and their associated field termi‐ nator character must be set with explicit entries in _f, as described in the OOUUTTPPUUTT FFOORR OOTTHHEERR PPRROOGGRRAAMMSS section. When a field selection character identifies an item _l_s_o_f does not normally list - e.g., PPID, selected with --RR - specifica‐ tion of the field character - e.g., ``--FFRR'' - also selects the listing of the item. When the field selection character list contains the single character `?', _l_s_o_f will display a help list of the field identification characters. (Escape the `?' character as your shell requires.) --gg _[_s_] excludes or 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.) PGID numbers that begin with `^' (negation) represent exclu‐ sions. Multiple PGID numbers are joined in a single ORed set before participating in AND option selection. However, PGID exclu‐ sions are applied without ORing or ANDing and take effect before other selection criteria are applied. The --gg option also enables the output display of PGID numbers. When specified without a PGID set that's all it does. --ii _[_i_] selects the listing of files any of whose Internet address matches the address specified in _i. If no address is speci‐ fied, this option selects the listing of all Internet and x.25 (HP-UX) network files. If --ii_4 or --ii_6 is specified with no following address, only files of the indicated IP version, IPv4 or IPv6, are dis‐ played. (An IPv6 specification may be used only if the dialects supports IPv6, as indicated by ``[46]'' and ``IPv[46]'' in _l_s_o_f_'_s --hh or --?? output.) Sequentially speci‐ fying --ii4, followed by --ii6 is the same as specifying --ii, and vice-versa. Specifying --ii4, or --ii6 after --ii is the same as specifying --ii4 or --ii6 by itself. Multiple addresses (up to a limit of 100) may be specified with multiple --ii 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. An Internet address is specified in the form (Items in square brackets are optional.): [_4_6][_p_r_o_t_o_c_o_l][@_h_o_s_t_n_a_m_e|_h_o_s_t_a_d_d_r][:_s_e_r_v_i_c_e|_p_o_r_t] where: _4_6 specifies the IP version, IPv4 or IPv6 that applies to the following address. '6' may be be specified only if the UNIX dialect supports IPv6. If neither '4' nor '6' is specified, the following address applies to all IP versions. _p_r_o_t_o_c_o_l is a protocol name - TTCCPP, UUDDPP _h_o_s_t_n_a_m_e is an Internet host name. Unless a specific IP version is specified, open network files associated with host names of all versions will be selected. _h_o_s_t_a_d_d_r is a numeric Internet IPv4 address in dot form; or an IPv6 numeric address in colon form, enclosed in brackets, if the UNIX dialect supports IPv6. When an IP version is selected, only its numeric addresses may be specified. _s_e_r_v_i_c_e is an _/_e_t_c_/_s_e_r_v_i_c_e_s name - e.g., ssmmttpp - or a list of them. _p_o_r_t is a port number, or a list of them. IPv6 options may be used only if the UNIX dialect supports IPv6. To see if the dialect supports IPv6, run _l_s_o_f and spec‐ ify the --hh or --?? (help) option. If the displayed description of the --ii option contains ``[46]'' and ``IPv[46]'', IPv6 is supported. IPv4 host names and addresses may not be specified if network file selection is limited to IPv6 with --ii 6. IPv6 host names and addresses may not be specified if network file selection is limited to IPv4 with --ii 4. When an open IPv4 network file's address is mapped in an IPv6 address, the open file's type will be IPv6, not IPv4, and its display will be selected by '6', not '4'. At least one address component - 44,, 66,, _p_r_o_t_o_c_o_l, _h_o_s_t_n_a_m_e, _h_o_s_t_a_d_d_r, or _s_e_r_v_i_c_e - must be supplied. The `@' character, leading the host specification, is always required; as is the `:', leading the port specification. Specify either _h_o_s_t_n_a_m_e or _h_o_s_t_a_d_d_r. Specify either _s_e_r_v_i_c_e name list or _p_o_r_t number list. If a _s_e_r_v_i_c_e name list is specified, the _p_r_o_t_o_c_o_l may also need to be specified if the TCP, UDP and UDPLITE port numbers for the service name are different. Use any case - lower or upper - for _p_r_o_t_o_c_o_l. _S_e_r_v_i_c_e names and _p_o_r_t 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 embed‐ ded spaces, and all service names must belong to the specified _p_r_o_t_o_c_o_l. Since service names may contain embedded minus signs, the starting entry of a range can't be a service name; it can be a port number, however. Here are some sample addresses: -i6 - IPv6 only TCP:25 - TCP and port 25 @1.2.3.4 - Internet IPv4 host address 1.2.3.4 @[3ffe:1ebc::1]:1234 - Internet IPv6 host address 3ffe:1ebc::1, port 1234 UDP:who - UDP who service port TCP@lsof.itap:513 - TCP, port 513 and host name lsof.itap tcp@foo:1-10,smtp,99 - TCP, ports 1 through 10, service name _s_m_t_p, port 99, host name foo tcp@bar:1-smtp - TCP, ports 1 through _s_m_t_p, host bar :time - either TCP, UDP or UDPLITE time service port --KK selects the listing of tasks (threads) of processes, on dialects where task (thread) reporting is supported. (If help output - i.e., the output of the --hh or --?? options - shows this option, then task (thread) reporting is supported by the dialect.) When --KK and --aa are both specified on Linux, and the tasks of a main process are selected by other options, the main process will also be listed as though it were a task, but without a task ID. (See the description of the TID column in the OOUUTTPPUUTT section.) Where the FreeBSD version supports threads, all threads will be listed with their IDs. In general threads and tasks inherit the files of the caller, but may close some and open others, so _l_s_o_f always reports all the open files of threads and tasks. --kk _k specifies a kernel name list file, _k, in place of /vmunix, /mach, etc. --kk is not available under AIX on the IBM RISC/System 6000. --ll inhibits the conversion of user ID numbers to login names. It is also useful when login name lookup is working improperly or slowly. ++||--LL _[_l_] 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. When ++LL is specified without a following number, all link counts will be listed. When --LL is specified (the default), no link counts will be listed. When ++LL is followed by a number, only files having a link count less than that number will be listed. (No number may follow --LL.) A specification of the form ``++LL11'' will select open files that have been unlinked. A specification of the form ``++aaLL11 _<_f_i_l_e___s_y_s_t_e_m_>'' will select unlinked open files on the specified file system. For other link count comparisons, use field output (--FF) and a post-processing script or program. ++||--mm _m specifies an alternate kernel memory file or activates mount table supplement processing. The option form --mm _m specifies a kernel memory file, _m, in place of _/_d_e_v_/_k_m_e_m or _/_d_e_v_/_m_e_m - e.g., a crash dump file. The option form ++mm requests that a mount supplement file be written to the standard output file. All other options are silently ignored. There will be a line in the mount supplement file for each mounted file system, containing the mounted file system direc‐ tory, followed by a single space, followed by the device num‐ ber in hexadecimal "0x" format - e.g., / 0x801 _L_s_o_f can use the mount supplement file to get device numbers for file systems when it can't get them via _s_t_a_t(2) or _l_s_t_a_t(2). The option form ++mm _m identifies _m as a mount supplement file. Note: the ++mm and ++mm _m options are not available for all sup‐ ported dialects. Check the output of _l_s_o_f_'_s --hh or --?? options to see if the ++mm and ++mm _m options are available. ++||--MM Enables (++) or disables (--) the reporting of portmapper regis‐ trations for local TCP, UDP and UDPLITE ports, where port map‐ ping is supported. (See the last paragraph of this option description for information about where portmapper registra‐ tion reporting is supported.) The default reporting mode is set by the _l_s_o_f builder with the HASPMAPENABLED #define in the dialect's machine.h header file; _l_s_o_f is distributed with the HASPMAPENABLED #define deacti‐ vated, so portmapper reporting is disabled by default and must be requested with ++MM. Specifying _l_s_o_f_'_s --hh or --?? option will report the default mode. Disabling portmapper registration when it is already disabled or enabling it when already enabled is acceptable. When portmapper registration reporting is enabled, _l_s_o_f displays the portmapper registration (if any) for local TCP, UDP or UDPLITE ports in square brackets immedi‐ ately following the port numbers or service names - e.g., ``:1234[name]'' or ``:name[100083]''. The registration infor‐ mation may be a name or number, depending on what the regis‐ tering program supplied to the portmapper when it registered the port. When portmapper registration reporting is enabled, _l_s_o_f 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 report‐ ing is slowing or blocking _l_s_o_f. For purposes of portmapper registration reporting _l_s_o_f consid‐ ers a TCP, UDP or UDPLITE 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 _l_s_o_f ignore some foreign ports on machines with multiple interfaces when the foreign Internet address is on a different interface from the local one. See the _l_s_o_f FAQ (The FFAAQQ section gives its location.) for further discussion of portmapper registration reporting issues. Portmapper registration reporting is supported only on dialects that have RPC header files. (Some Linux distribu‐ tions with GlibC 2.14 do not have them.) When portmapper reg‐ istration reporting is supported, the --hh or --?? help output will show the ++||--MM option. --nn inhibits the conversion of network numbers to host names for network files. Inhibiting conversion may make _l_s_o_f run faster. It is also useful when host name lookup is not work‐ ing properly. --NN selects the listing of NFS files. --oo directs _l_s_o_f 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 _l_s_o_f can't obtain accurate or con‐ sistent file offset information from its kernel data sources, sometimes just for particular kinds of files (e.g., socket files.) Consult the _l_s_o_f FAQ (The FFAAQQ section gives its loca‐ tion.) for more information. The --oo and --ss options are mutually exclusive; they can't both be specified. When neither is specified, _l_s_o_f displays what‐ ever value - size or offset - is appropriate and available for the type of the file. --oo _o 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 _l_s_o_f to use the ``0t'' form for all offset output. This option does NOT direct _l_s_o_f to display offset at all times; specify --oo (without a trailing number) to do that. --oo _o only specifies the number of digits after ``0t'' in either mixed size and offset or offset-only output. Thus, for exam‐ ple, to direct _l_s_o_f to display offset at all times with a dec‐ imal digit count of 10, use: -o -o 10 or -oo10 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 --oo _o option in the output of the --hh or --?? option to determine the default that is in effect. --OO directs _l_s_o_f to bypass the strategy it uses to avoid being blocked by some kernel operations - i.e., doing them in forked child processes. See the BBLLOOCCKKSS AANNDD TTIIMMEEOOUUTTSS and AAVVOOIIDDIINNGG KKEERRNNEELL BBLLOOCCKKSS sections for more information on kernel opera‐ tions that may block _l_s_o_f. While use of this option will reduce _l_s_o_f startup overhead, it may also cause _l_s_o_f to hang when the kernel doesn't respond to a function. Use this option cautiously. --pp _s excludes or selects the listing of files for the processes whose optional process IDentification (PID) numbers are in the comma-separated set _s - e.g., ``123'' or ``123,^456''. (There should be no spaces in the set.) PID numbers that begin with `^' (negation) represent exclu‐ sions. Multiple process ID numbers are joined in a single ORed set before participating in AND option selection. However, PID exclusions are applied without ORing or ANDing and take effect before other selection criteria are applied. --PP inhibits the conversion of port numbers to port names for net‐ work files. Inhibiting the conversion may make _l_s_o_f run a little faster. It is also useful when port name lookup is not working properly. ++||--rr _[_t_[_m_<_f_m_t_>_]_] puts _l_s_o_f in repeat mode. There _l_s_o_f 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. If the prefix is a `-', repeat mode is endless. _L_s_o_f must be terminated with an interrupt or quit signal. If the prefix is `+', repeat mode will end the first cycle no open files are listed - and of course when _l_s_o_f 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. _L_s_o_f marks the end of each listing: if field output is in progress (the --FF, option has been specified), the default marker is `m'; otherwise the default marker is ``========''. The marker is followed by a NL character. The optional "m<fmt>" argument specifies a format for the marker line. The <fmt> characters following `m' are inter‐ preted as a format specification to the _s_t_r_f_t_i_m_e(3) function, when both it and the _l_o_c_a_l_t_i_m_e(3) function are available in the dialect's C library. Consult the _s_t_r_f_t_i_m_e(3) documenta‐ tion for what may appear in its format specification. Note that when field output is requested with the --FF option, <fmt> cannot contain the NL format, ``%n''. Note also that when <fmt> contains spaces or other characters that affect the shell's interpretation of arguments, <fmt> must be quoted appropriately. Repeat mode reduces _l_s_o_f startup overhead, so it is more effi‐ cient to use this mode than to call _l_s_o_f repetitively from a shell script, for example. To use repeat mode most efficiently, accompany ++||--rr with spec‐ ification of other _l_s_o_f selection options, so the amount of kernel memory access _l_s_o_f does will be kept to a minimum. Options that filter at the process level - e.g., --cc, --gg, --pp, --uu - are the most efficient selectors. Repeat mode is useful when coupled with field output (see the --FF, option description) and a supervising _a_w_k or _P_e_r_l script, or a C program. --RR directs lsof to list the Parent Process IDentification number in the PPID column. --ss _[_p_:_s_] ss alone directs _l_s_o_f 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. The optional --ss _p_:_s form is available only for selected dialects, and only when the --hh or --?? help output lists it. When the optional form is available, the ss may be followed by a protocol name (_p), either TCP or UDP, a colon (`:') and a comma-separated protocol state name list, the option causes open TCP and UDP files to be excluded if their state name(s) are in the list (_s) preceded by a `^'; or included if their name(s) are not preceded by a `^'. When an inclusion list is defined, only network files with state names in the list will be present in the _l_s_o_f output. Thus, specifying one state name means that only network files with that lone state name will be listed. Case is unimportant in the protocol or state names, but there may be no spaces and the colon (`:') separating the protocol name (_p) and the state name list (_s) is required. If only TCP and UDP files are to be listed, as controlled by the specified exclusions and inclusions, the --ii option must be specified, too. If only a single protocol's files are to be listed, add its name as an argument to the --ii option. For example, to list only network files with TCP state LISTEN, use: -iTCP -sTCP:LISTEN Or, for example, to list network files with all UDP states except Idle, use: -iUDP -sUDP:Idle State names vary with UNIX dialects, so it's not possible to provide a complete list. Some common TCP state names are: CLOSED, IDLE, BOUND, LISTEN, ESTABLISHED, SYN_SENT, SYN_RCDV, ESTABLISHED, CLOSE_WAIT, FIN_WAIT1, CLOSING, LAST_ACK, FIN_WAIT_2, and TIME_WAIT. Two common UDP state names are Unbound and Idle. See the _l_s_o_f FAQ (The FFAAQQ section gives its location.) for more information on how to use protocol state exclusion and inclusion, including examples. The --oo (without a following decimal digit count) and --ss option (without a following protocol and state name list) are mutu‐ ally exclusive; they can't both be specified. When neither is specified, _l_s_o_f displays whatever value - size or offset - is appropriate and available for the type of file. 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. --SS _[_t_] specifies an optional time-out seconds value for kernel func‐ tions - _l_s_t_a_t(2), _r_e_a_d_l_i_n_k(2), and _s_t_a_t(2) - that might other‐ wise deadlock. The minimum for _t is two; the default, fif‐ teen; when no value is specified, the default is used. See the BBLLOOCCKKSS AANNDD TTIIMMEEOOUUTTSS section for more information. --TT _[_t_] controls the reporting of some TCP/TPI information, also reported by _n_e_t_s_t_a_t(1), following the network addresses. In normal output the information appears in parentheses, each item except TCP or TPI state name identified by a keyword, followed by `=', separated from others by a single space: <TCP or TPI state name> QR=<read queue length> QS=<send queue length> SO=<socket options and values> SS=<socket states> TF=<TCP flags and values> WR=<window read length> WW=<window write length> Not all values are reported for all UNIX dialects. Items val‐ ues (when available) are reported after the item name and '='. When the field output mode is in effect (See OOUUTTPPUUTT FFOORR OOTTHHEERR PPRROOGGRRAAMMSS.) each item appears as a field with a `T' leading character. --TT with no following key characters disables TCP/TPI informa‐ tion reporting. --TT with following characters selects the reporting of specific TCP/TPI information: ff selects reporting of socket options, states and values, and TCP flags and values. qq selects queue length reporting. ss selects connection state reporting. ww selects window size reporting. Not all selections are enabled for some UNIX dialects. State may be selected for all dialects and is reported by default. The --hh or --?? help output for the --TT option will show what selections may be used with the UNIX dialect. When --TT 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 --TT. (In effect, then, the default is equivalent to --TTss.) For example, if queue lengths and state are desired, use --TTqqss. Socket options, socket states, some socket values, TCP flags and one TCP value may be reported (when available in the UNIX dialect) in the form of the names that commonly appear after SO_, so_, SS_, TCP_ and TF_ in the dialect's header files - most often <sys/socket.h>, <sys/socketvar.h> and <netinet/tcp_var.h>. Consult those header files for the mean‐ ing of the flags, options, states and values. ``SO='' precedes socket options and values; ``SS='', socket states; and ``TF='', TCP flags and values. If a flag or option has a value, the value will follow an '=' and the name -- e.g., ``SO=LINGER=5'', ``SO=QLIM=5'', ``TF=MSS=512''. The following seven values may be reported: Name Reported Description (Common Symbol) KEEPALIVE keep alive time (SO_KEEPALIVE) LINGER linger time (SO_LINGER) MSS maximum segment size (TCP_MAXSEG) PQLEN partial listen queue connections QLEN established listen queue connections QLIM established listen queue limit RCVBUF receive buffer length (SO_RCVBUF) SNDBUF send buffer length (SO_SNDBUF) Details on what socket options and values, socket states, and TCP flags and values may be displayed for particular UNIX dialects may be found in the answer to the ``Why doesn't lsof report socket options, socket states, and TCP flags and values for my dialect?'' and ``Why doesn't lsof report the partial listen queue connection count for my dialect?'' questions in the _l_s_o_f FAQ (The FFAAQQ section gives its location.) --tt specifies that _l_s_o_f should produce terse output with process identifiers only and no header - e.g., so that the output may be piped to _k_i_l_l(1). --tt selects the --ww option. --uu _s 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.) Multiple login names or user ID numbers are joined in a single ORed set before participating in AND option selection. 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 _l_s_o_f to exclude the listing of files belonging to root processes, specify ``-u^root'' or ``-u^0''. --UU selects the listing of UNIX domain socket files. --vv selects the listing of _l_s_o_f version information, including: revision number; when the _l_s_o_f binary was constructed; who constructed the binary and where; the name of the compiler used to construct the _l_s_o_f _b_i_n_a_r_y_; the version number of the compiler when readily available; the compiler and loader flags used to construct the _l_s_o_f binary; and system information, typically the output of _u_n_a_m_e's --aa option. --VV directs _l_s_o_f 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. When other options are ANDed to search options, or com‐ pile-time options restrict the listing of some files, _l_s_o_f may not report that it failed to find a search item when an ANDed option or compile-time 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. A similar situation arises when HASSECURITY and HASNOSOCKSECU‐ RITY are defined at compile time and they prevent the listing of open files. ++||--ww Enables (++) or disables (--) the suppression of warning mes‐ sages. The _l_s_o_f builder may choose to have warning messages disabled or enabled by default. The default warning message state is indicated in the output of the --hh or --?? option. Disabling warning messages when they are already disabled or enabling them when already enabled is acceptable. The --tt option selects the --ww option. --xx _[_f_l_] may accompany the ++dd and ++DD options to direct their processing to cross over symbolic links and|or file system mount points encountered when scanning the directory (++dd) or directory tree (++DD). If --xx is specified by itself without a following parameter, cross-over processing of both symbolic links and file system mount points is enabled. Note that when --xx is specified with‐ out a parameter, the next argument must begin with '-' or '+'. The optional 'f' parameter enables file system mount point cross-over processing; 'l', symbolic link cross-over process‐ ing. The --xx option may not be supplied without also supplying a ++dd or ++DD option. --XX This is a dialect-specific option. AIX: This IBM AIX RISC/System 6000 option requests the reporting of executed text file and shared library references. WWAARRNNIINNGG:: because this option uses the kernel readx() function, its use 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 its happening, but I think there is a remote possibility it could happen. By default use of readx() is disabled. On AIX 5L and above _l_s_o_f may need setuid-root permission to perform the actions this option requests. The _l_s_o_f builder may specify that the --XX option be restricted to processes whose real UID is root. If that has been done, the --XX option will not appear in the --hh or --?? help output unless the real UID of the _l_s_o_f process is root. The default _l_s_o_f distribution allows any UID to specify --XX,, so by default it will appear in the help output. When AIX readx() use is disabled, _l_s_o_f 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. The readx() function, used by _l_s_o_f 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 to believe erroneously that part of an in-memory copy of a file system directory has been zeroed. Another applica‐ tion process, distinct from _l_s_o_f, asking the kernel to search the directory - e.g., by using _o_p_e_n(2) - can cause dir_search() to loop forever, thus hanging the application process. Consult the _l_s_o_f FAQ (The FFAAQQ section gives its location.) and the _0_0_R_E_A_D_M_E file of the _l_s_o_f distribution for a more com‐ plete description of the Stale Segment ID bug, its APAR, and methods for defining readx() use when compiling _l_s_o_f. Linux: This Linux option requests that _l_s_o_f skip the reporting of information on all open TCP, UDP and UDPLITE IPv4 and IPv6 files. This Linux option is most useful when the system has an extremely large number of open TCP, UDP and UDPLITE files, the processing of whose information in the _/_p_r_o_c_/_n_e_t_/_t_c_p_* and _/_p_r_o_c_/_n_e_t_/_u_d_p_* files would take _l_s_o_f a long time, and whose reporting is not of interest. Use this option with care and only when you are sure that the information you want _l_s_o_f to display isn't associated with open TCP, UDP or UDPLITE socket files. Solaris 10 and above: This Solaris 10 and above option requests the reporting of cached paths for files that have been deleted - i.e., removed with _r_m(1) or _u_n_l_i_n_k(2). The cached path is followed by the string `` (deleted)'' to indicate that the path by which the file was opened has been deleted. Because intervening changes made to the path - i.e., renames with _m_v(1) or _r_e_n_a_m_e(2) - are not recorded in the cached path, what _l_s_o_f reports is only the path by which the file was opened, not its possibly different final path. --zz _[_z_] specifies how Solaris 10 and higher zone information is to be handled. Without a following argument - e.g., NO _z - the option speci‐ fies that zone names are to be listed in the ZONE output col‐ umn. The --zz option may be followed by a zone name, zz_. That causes lsof to list only open files for processes in that zone. Mul‐ tiple --zz _z option and argument pairs may be specified to form a list of named zones. Any open file of any process in any of the zones will be listed, subject to other conditions speci‐ fied by other options and arguments. --ZZ _[_Z_] specifies how SELinux security contexts are to be handled. It and 'Z' field output character support are inhibited when SELinux is disabled in the running Linux kernel. See OOUUTTPPUUTT FFOORR OOTTHHEERR PPRROOGGRRAAMMSS for more information on the 'Z' field out‐ put character. Without a following argument - e.g., NO _Z - the option speci‐ fies that security contexts are to be listed in the SECU‐ RITY-CONTEXT output column. The --ZZ option may be followed by a wildcard security context name, ZZ_. That causes lsof to list only open files for pro‐ cesses in that security context. Multiple --ZZ _Z option and argument pairs may be specified to form a list of security contexts. Any open file of any process in any of the security contexts will be listed, subject to other conditions specified by other options and arguments. Note that _Z can be A:B:C or *:B:C or A:B:* or *:*:C to match against the A:B:C context. ---- 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. _n_a_m_e_s These are path names of specific files to list. Symbolic links are resolved before use. The first name may be sepa‐ rated from the preceding options with the ``--'' option. If a _n_a_m_e is the mounted-on directory of a file system or the device of the file system, _l_s_o_f will list all the files open on the file system. To be considered a file system, the _n_a_m_e must match a mounted-on directory name in _m_o_u_n_t(8) output, or match the name of a block device associated with a mounted-on directory name. The ++||--ff option may be used to force _l_s_o_f to consider a _n_a_m_e a file system identifier (++ff) or a simple file (--ff). If _n_a_m_e is a path to a directory that is not the mounted-on directory name of a file system, it is treated just as a regu‐ lar file is treated - i.e., its listing is restricted to pro‐ cesses that have it open as a file or as a process-specific directory, such as the root or current working directory. To request that _l_s_o_f look for open files inside a directory name, use the ++dd _s and ++DD _D options. If a _n_a_m_e is the base name of a family of multiplexed files - e.g, AIX's _/_d_e_v_/_p_t_[_c_s_] - _l_s_o_f will list all the associated multiplexed files on the device that are open - e.g., _/_d_e_v_/_p_t_[_c_s_]_/_1, _/_d_e_v_/_p_t_[_c_s_]_/_2, etc. If a _n_a_m_e is a UNIX domain socket name, _l_s_o_f will usually search for it by the characters of the name alone - exactly as it is specified and is recorded in the kernel socket struc‐ ture. (See the next paragraph for an exception to that rule for Linux.) Specifying a relative path - e.g., _._/_f_i_l_e - in place of the file's absolute path - e.g., _/_t_m_p_/_f_i_l_e - won't work because _l_s_o_f must match the characters you specify with what it finds in the kernel UNIX domain socket structures. If a _n_a_m_e is a Linux UNIX domain socket name, in one case _l_s_o_f is able to search for it by its device and inode number, allowing _n_a_m_e to be a relative path. The case requires that the absolute path -- i.e., one beginning with a slash ('/') be used by the process that created the socket, and hence be stored in the _/_p_r_o_c_/_n_e_t_/_u_n_i_x file; and it requires that _l_s_o_f be able to obtain the device and node numbers of both the absolute path in _/_p_r_o_c_/_n_e_t_/_u_n_i_x and _n_a_m_e via successful _s_t_a_t(2) system calls. When those conditions are met, _l_s_o_f will be able to search for the UNIX domain socket when some path to it is is specified in _n_a_m_e. Thus, for example, if the path is _/_d_e_v_/_l_o_g, and an _l_s_o_f search is initiated when the working directory is _/_d_e_v, then _n_a_m_e could be _._/_l_o_g. If a _n_a_m_e is none of the above, _l_s_o_f will list any open files whose device and inode match that of the specified path _n_a_m_e. If you have also specified the --bb option, the only _n_a_m_e_s you may safely specify are file systems for which your mount table supplies alternate device numbers. See the AAVVOOIIDDIINNGG KKEERRNNEELL BBLLOOCCKKSS and AALLTTEERRNNAATTEE DDEEVVIICCEE NNUUMMBBEERRSS sections for more informa‐ tion. Multiple file names are joined in a single ORed set before participating in AND option selection. AAFFSS _L_s_o_f supports the recognition of AFS files for these dialects (and AFS versions): AIX 4.1.4 (AFS 3.4a) HP-UX 9.0.5 (AFS 3.4a) Linux 1.2.13 (AFS 3.3) Solaris 2.[56] (AFS 3.4a) It may recognize AFS files on other versions of these dialects, but has not been tested there. Depending on how AFS is implemented, _l_s_o_f may recognize AFS files in other dialects, or may have difficulties recog‐ nizing AFS files in the supported dialects. _L_s_o_f 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, _l_s_o_f 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 _l_s_o_f can't com‐ pute volume node numbers, it reports blank in the NODE column. The --AA _A option is available in some dialect implementations of _l_s_o_f 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 _l_s_o_f help output, presented in response to the --hh or --?? See the _l_s_o_f FAQ (The FFAAQQ section gives its location.) for more infor‐ mation about dynamic modules, their symbols, and how they affect _l_s_o_f options. Because AFS path lookups don't seem to participate in the kernel's name cache operations, _l_s_o_f can't identify path name components for AFS files. SSEECCUURRIITTYY _L_s_o_f 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 _l_s_o_f. (The list-all-open-files and device cache features may be dis‐ abled when _l_s_o_f is compiled.) Third, its --kk and --mm options name alter‐ nate kernel name list or memory files. Restricting the listing of all open files is controlled by the com‐ pile-time HASSECURITY and HASNOSOCKSECURITY options. When HASSECURITY is defined, _l_s_o_f 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 _l_s_o_f process (the one that its user logged on with). However, if HASSECURITY and HASNOSOCKSECURITY are both defined, anyone may list open socket files, provided they are selected with the --ii option. When HASSECURITY is not defined, anyone may list all open files. Help output, presented in response to the --hh or --?? option, gives the status of the HASSECURITY and HASNOSOCKSECURITY definitions. See the SSeeccuurriittyy section of the _0_0_R_E_A_D_M_E file of the _l_s_o_f distribution for information on building _l_s_o_f with the HASSECURITY and HASNOSOCKSE‐ CURITY options enabled. Creation and use of a user-readable and user-writable device cache file is controlled by the compile-time HASDCACHE option. See the DDEEVVIICCEE CCAACCHHEE FFIILLEE 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 _l_s_o_f distribution, if the real user ID under which _l_s_o_f is executed is root, the device cache file will be written in root's home directory - e.g., _/ or _/_r_o_o_t. When HASDCACHE is not defined, _l_s_o_f does not write or attempt to read a device cache file. When HASDCACHE is defined, the _l_s_o_f help output, presented in response to the --hh, --DD??, or --?? options, will provide device cache file handling information. When HASDCACHE is not defined, the --hh or --?? output will have no --DD option description. Before you decide to disable the device cache file feature - enabling it improves the performance of _l_s_o_f by reducing the startup overhead of examining all the nodes in _/_d_e_v (or _/_d_e_v_i_c_e_s) - read the discussion of it in the _0_0_D_C_A_C_H_E file of the _l_s_o_f distribution and the _l_s_o_f FAQ (The FFAAQQ section gives its location.) WHEN IN DOUBT, YOU CAN TEMPORARILY DISABLE THE USE OF THE DEVICE CACHE FILE WITH THE --DDii OPTION. When _l_s_o_f user declares alternate kernel name list or memory files with the --kk and --mm options, _l_s_o_f checks the user's authority to read them with _a_c_c_e_s_s(2). This is intended to prevent whatever special power _l_s_o_f_'_s modes might confer on it from letting it read files not normally accessible via the authority of the real user ID. OOUUTTPPUUTT This section describes the information _l_s_o_f lists for each open file. See the OOUUTTPPUUTT FFOORR OOTTHHEERR PPRROOGGRRAAMMSS section for additional information on output that can be processed by another program. _L_s_o_f only outputs printable (declared so by _i_s_p_r_i_n_t(3)) 8 bit charac‐ ters. 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-print‐ able in the COMMAND column (``\x20'') and printable elsewhere. For some dialects - if HASSETLOCALE is defined in the dialect's machine.h header file - _l_s_o_f will print the extended 8 bit characters of a language locale. The _l_s_o_f process must be supplied a language locale environment variable (e.g., LANG) whose value represents a known language locale in which the extended characters are considered print‐ able by _i_s_p_r_i_n_t(3). Otherwise _l_s_o_f considers the extended characters non-printable and prints them according to its rules for non-printable characters, stated above. Consult your dialect's _s_e_t_l_o_c_a_l_e(3) man page for the names of other environment variables that may be used in place of LANG - e.g., LC_ALL, LC_CTYPE, etc. _L_s_o_f_'_s language locale support for a dialect also covers wide charac‐ ters - e.g., UTF-8 - when HASSETLOCALE and HASWIDECHAR are defined in the dialect's machine.h header file, and when a suitable language locale has been defined in the appropriate environment variable for the _l_s_o_f process. Wide characters are printable under those conditions if _i_s_w_p_r_i_n_t(3) reports them to be. If HASSETLOCALE, HASWIDECHAR and a suitable language locale aren't defined, or if _i_s_w_p_r_i_n_t(3) reports wide characters that aren't printable, _l_s_o_f considers the wide characters non-printable and prints each of their 8 bits according to its rules for non-printable characters, stated above. Consult the answers to the "Language locale support" questions in the lsof FAQ (The FFAAQQ section gives its location.) for more information. _L_s_o_f dynamically sizes the output columns each time it runs, guarantee‐ ing that each column is a minimum size. It also guarantees that each column is separated from its predecessor by at least one space. COMMAND contains the first nine characters of the name of the UNIX command associated with the process. If a non-zero _w value is specified to the ++cc _w option, the column contains the first _w characters of the name of the UNIX command associ‐ ated with the process up to the limit of characters supplied to _l_s_o_f by the UNIX dialect. (See the description of the ++cc _w command or the _l_s_o_f FAQ for more information. The FFAAQQ section gives its location.) If _w is less than the length of the column title, ``COM‐ MAND'', it will be raised to that length. If a zero _w value is specified to the ++cc _w option, the col‐ umn contains all the characters of the name of the UNIX com‐ mand associated with the process. 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 OOUUTTPPUUTT FFOORR OOTTHHEERR CCOOMMMMAANNDDSS section for information on selecting field output and the associated command name descriptor. PID is the Process IDentification number of the process. TID is the task (thread) IDentification number, if task (thread) reporting is supported by the dialect and a task (thread) is being listed. (If help output - i.e., the output of the --hh or --?? options - shows this option, then task (thread) reporting is supported by the dialect.) A blank TID column in Linux indicates a process - i.e., a non-task. ZONE is the Solaris 10 and higher zone name. This column must be selected with the --zz option. SECURITY-CONTEXT is the SELinux security context. This column must be selected with the --ZZ option. Note that the --ZZ option is inhibited when SELinux is disabled in the running Linux ker‐ nel. PPID is the Parent Process IDentification number of the process. It is only displayed when the --RR option has been specified. PGID is the process group IDentification number associated with the process. It is only displayed when the --gg option has been specified. USER is the user ID number or login name of the user to whom the process belongs, usually the same as reported by _p_s(1). However, on Linux USER is the user ID number or login that owns the directory in /proc where _l_s_o_f finds information about the process. Usually that is the same value reported by _p_s(1), but may differ when the process has changed its effective user ID. (See the --ll option description for information on when a user ID number or login name is dis‐ played.) FD is the File Descriptor number of the file or: ccwwdd current working directory; LL_n_n library references (AIX); eerrrr FD information error (see NAME column); jjlldd jail directory (FreeBSD); llttxx shared library text (code and data); MMxxxx hex memory-mapped type number xx. mm8866 DOS Merge mapped file; mmeemm memory-mapped file; mmmmaapp memory-mapped device; ppdd parent directory; rrttdd root directory; ttrr kernel trace file (OpenBSD); ttxxtt program text (code and data); vv8866 VP/ix mapped file; FD is followed by one of these characters, describing the mode under which the file is open: rr for read access; ww for write access; uu for read and write access; space if mode unknown and no lock character follows; `-' if mode unknown and lock character follows. The mode character is followed by one of these lock charac‐ ters, describing the type of lock applied to the file: NN for a Solaris NFS lock of unknown type; rr for read lock on part of the file; RR for a read lock on the entire file; ww for a write lock on part of the file; WW for a write lock on the entire file; uu for a read and write lock of any length; UU for a lock of unknown type; xx for an SCO OpenServer Xenix lock on part of the file; XX for an SCO OpenServer Xenix lock on the entire file; space if there is no lock. See the LLOOCCKKSS section for more information on the lock information character. The FD column contents constitutes a single field for pars‐ ing in post-processing scripts. TYPE is the type of the node associated with the file - e.g., GDIR, GREG, VDIR, VREG, etc. or ``IPv4'' for an IPv4 socket; or ``IPv6'' for an open IPv6 network file - even if its address is IPv4, mapped in an IPv6 address; or ``ax25'' for a Linux AX.25 socket; or ``inet'' for an Internet domain socket; or ``lla'' for a HP-UX link level access file; or ``rte'' for an AF_ROUTE socket; or ``sock'' for a socket of unknown domain; or ``unix'' for a UNIX domain socket; or ``x.25'' for an HP-UX x.25 socket; or ``BLK'' for a block special file; or ``CHR'' for a character special file; or ``DEL'' for a Linux map file that has been deleted; or ``DIR'' for a directory; or ``DOOR'' for a VDOOR file; or ``FIFO'' for a FIFO special file; or ``KQUEUE'' for a BSD style kernel event queue file; or ``LINK'' for a symbolic link file; or ``MPB'' for a multiplexed block file; or ``MPC'' for a multiplexed character file; or ``NOFD'' for a Linux /proc/<PID>/fd directory that can't be opened -- the directory path appears in the NAME column, followed by an error message; or ``PAS'' for a _/_p_r_o_c_/_a_s file; or ``PAXV'' for a _/_p_r_o_c_/_a_u_x_v file; or ``PCRE'' for a _/_p_r_o_c_/_c_r_e_d file; or ``PCTL'' for a _/_p_r_o_c control file; or ``PCUR'' for the current _/_p_r_o_c process; or ``PCWD'' for a _/_p_r_o_c current working directory; or ``PDIR'' for a _/_p_r_o_c directory; or ``PETY'' for a _/_p_r_o_c executable type (_e_t_y_p_e); or ``PFD'' for a _/_p_r_o_c file descriptor; or ``PFDR'' for a _/_p_r_o_c file descriptor directory; or ``PFIL'' for an executable _/_p_r_o_c file; or ``PFPR'' for a _/_p_r_o_c FP register set; or ``PGD'' for a _/_p_r_o_c_/_p_a_g_e_d_a_t_a file; or ``PGID'' for a _/_p_r_o_c group notifier file; or ``PIPE'' for pipes; or ``PLC'' for a _/_p_r_o_c_/_l_w_p_c_t_l file; or ``PLDR'' for a _/_p_r_o_c_/_l_p_w directory; or ``PLDT'' for a _/_p_r_o_c_/_l_d_t file; or ``PLPI'' for a _/_p_r_o_c_/_l_p_s_i_n_f_o file; or ``PLST'' for a _/_p_r_o_c_/_l_s_t_a_t_u_s file; or ``PLU'' for a _/_p_r_o_c_/_l_u_s_a_g_e file; or ``PLWG'' for a _/_p_r_o_c_/_g_w_i_n_d_o_w_s file; or ``PLWI'' for a _/_p_r_o_c_/_l_w_p_s_i_n_f_o file; or ``PLWS'' for a _/_p_r_o_c_/_l_w_p_s_t_a_t_u_s file; or ``PLWU'' for a _/_p_r_o_c_/_l_w_p_u_s_a_g_e file; or ``PLWX'' for a _/_p_r_o_c_/_x_r_e_g_s file; or ``PMAP'' for a _/_p_r_o_c map file (_m_a_p); or ``PMEM'' for a _/_p_r_o_c memory image file; or ``PNTF'' for a _/_p_r_o_c process notifier file; or ``POBJ'' for a _/_p_r_o_c_/_o_b_j_e_c_t file; or ``PODR'' for a _/_p_r_o_c_/_o_b_j_e_c_t directory; or ``POLP'' for an old format _/_p_r_o_c light weight process file; or ``POPF'' for an old format _/_p_r_o_c PID file; or ``POPG'' for an old format _/_p_r_o_c page data file; or ``PORT'' for a SYSV named pipe; or ``PREG'' for a _/_p_r_o_c register file; or ``PRMP'' for a _/_p_r_o_c_/_r_m_a_p file; or ``PRTD'' for a _/_p_r_o_c root directory; or ``PSGA'' for a _/_p_r_o_c_/_s_i_g_a_c_t file; or ``PSIN'' for a _/_p_r_o_c_/_p_s_i_n_f_o file; or ``PSTA'' for a _/_p_r_o_c status file; or ``PSXSEM'' for a POSIX semaphore file; or ``PSXSHM'' for a POSIX shared memory file; or ``PUSG'' for a _/_p_r_o_c_/_u_s_a_g_e file; or ``PW'' for a _/_p_r_o_c_/_w_a_t_c_h file; or ``PXMP'' for a _/_p_r_o_c_/_x_m_a_p file; or ``REG'' for a regular file; or ``SMT'' for a shared memory transport file; or ``STSO'' for a stream socket; or ``UNNM'' for an unnamed type file; or ``XNAM'' for an OpenServer Xenix special file of unknown type; or ``XSEM'' for an OpenServer Xenix semaphore file; or ``XSD'' for an OpenServer Xenix shared data file; or the four type number octets if the corresponding name isn't known. FILE-ADDR contains the kernel file structure address when ff has been specified to ++ff; FCT contains the file reference count from the kernel file structure when cc has been specified to ++ff; FILE-FLAG when gg or GG has been specified to ++ff, 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 semi‐ colon (`;'); the first list may contain short-hand names for f_flag[s] values from the following table: AIO asynchronous I/O (e.g., FAIO) AP append ASYN asynchronous I/O (e.g., FASYNC) BAS block, test, and set in use BKIU block if in use BL use block offsets BSK block seek CA copy avoid CIO concurrent I/O CLON clone CLRD CL read CR create DF defer DFI defer IND DFLU data flush DIR direct DLY delay DOCL do clone DSYN data-only integrity DTY must be a directory EVO event only EX open for exec EXCL exclusive open FSYN synchronous writes GCDF defer during unp_gc() (AIX) GCMK mark during unp_gc() (AIX) GTTY accessed via /dev/tty HUP HUP in progress KERN kernel KIOC kernel-issued ioctl LCK has lock LG large file MBLK stream message block MK mark MNT mount MSYN multiplex synchronization NATM don't update atime NB non-blocking I/O NBDR no BDRM check NBIO SYSV non-blocking I/O NBF n-buffering in effect NC no cache ND no delay NDSY no data synchronization NET network NFLK don't follow links NMFS NM file system NOTO disable background stop NSH no share NTTY no controlling TTY OLRM OLR mirror PAIO POSIX asynchronous I/O PP POSIX pipe R read RC file and record locking cache REV revoked RSH shared read RSYN read synchronization RW read and write access SL shared lock SNAP cooked snapshot SOCK socket SQSH Sequent shared set on open SQSV Sequent SVM set on open SQR Sequent set repair on open SQS1 Sequent full shared open SQS2 Sequent partial shared open STPI stop I/O SWR synchronous read SYN file integrity while writing TCPM avoid TCP collision TR truncate W write WKUP parallel I/O synchronization WTG parallel I/O synchronization VH vhangup pending VTXT virtual text XL exclusive lock 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; the second list (after the semicolon) may contain short-hand names for kernel per-process open file flags from this ta‐ ble: ALLC allocated BR the file has been read BHUP activity stopped by SIGHUP BW the file has been written CLSG closing CX close-on-exec (see fcntl(F_SETFD)) LCK lock was applied MP memory-mapped OPIP open pending - in progress RSVW reserved wait SHMT UF_FSHMAT set (AIX) USE in use (multi-threaded) NODE-ID (or INODE-ADDR for some dialects) contains a unique identi‐ fier for the file node (usually the kernel vnode or inode address, but also occasionally a concatenation of device and node number) when nn has been specified to ++ff; DEVICE contains the device numbers, separated by commas, for a character special, block special, regular, directory or NFS file; or ``memory'' for a memory file system node under Tru64 UNIX; or the address of the private data area of a Solaris socket stream; or a kernel reference address that identifies the file (The kernel reference address may be used for FIFO's, for exam‐ ple.); or the base address or device name of a Linux AX.25 socket device. Usually only the lower thirty two bits of Tru64 UNIX kernel addresses are displayed. 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. _L_s_o_f displays whatever value - size or offset - is appropri‐ ate for the type of the file and the version of _l_s_o_f. On some UNIX dialects _l_s_o_f can't obtain accurate or consis‐ tent 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 _l_s_o_f 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 _l_s_o_f FAQ (The FFAAQQ section gives its location.) for more information. The file size is displayed in decimal; the offset is nor‐ mally displayed in decimal with a leading ``0t'' if it con‐ tains 8 digits or less; in hexadecimal with a leading ``0x'' if it is longer than 8 digits. (Consult the --oo _o option description for information on when 8 might default to some other value.) 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). If the --oo option is specified, _l_s_o_f 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. The _l_s_o_f user can control the switch from ``0t'' to ``0x'' with the --oo _o option. Consult its description for more information. If the --ss option is specified, _l_s_o_f always displays the file size (or nothing if no size is available) and labels the column SIZE. The --oo and --ss options are mutually exclusive; they can't both be specified. For files that don't have a fixed size - e.g., don't reside on a disk device - _l_s_o_f 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. NLINK contains the file link count when ++LL has been specified; NODE is the node number of a local file; or the inode number of an NFS file in the server host; or the Internet protocol type - e.g, ``TCP''; or ``STR'' for a stream; or ``CCITT'' for an HP-UX x.25 socket; or the IRQ or inode number of a Linux AX.25 socket device. NAME is the name of the mount point and file system on which the file resides; or the name of a file specified in the _n_a_m_e_s option (after any symbolic links have been resolved); or the name of a character special or block special device; 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 ++||--MM, --nn, and --PP options; colon-separated IPv6 numbers are enclosed in square brackets; IPv4 INADDR_ANY and IPv6 IN6_IS_ADDR_UNSPECIFIED addresses, and zero port numbers 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 destina‐ tion; TCP, UDP and UDPLITE 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 _n_e_t_‐ _s_t_a_t(1) reports; see the --TT option description or the description of the TCP/TPI field in OOUUTTPPUUTT FFOORR OOTTHHEERR PPRROO‐‐ GGRRAAMMSS for more information on state, queue size, and window size; 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; or the local and remote mount point names of an NFS file; or ``STR'', followed by the stream name; or a stream character device name, followed by ``->'' and the stream name or a list of stream module names, separated by ``->''; or ``STR:'' followed by the SCO OpenServer stream device and module names, separated by ``->''; or system directory name, `` -- '', and as many components of the path name as _l_s_o_f can find in the kernel's name cache for selected dialects (See the KKEERRNNEELL NNAAMMEE CCAACCHHEE section for more information.); or ``PIPE->'', followed by a Solaris kernel pipe destination address; or ``COMMON:'', followed by the vnode device information structure's device name, for a Solaris common vnode; or the address family, followed by a slash (`/'), followed by fourteen comma-separated bytes of a non-Internet raw socket address; or the HP-UX x.25 local address, followed by the virtual connection number (if any), followed by the remote address (if any); or ``(dead)'' for disassociated Tru64 UNIX files - typically terminal files that have been flagged with the TIOCNOTTY ioctl and closed by daemons; or ``rd=<offset>'' and ``wr=<offset>'' for the values of the read and write offsets of a FIFO; or ``clone _n:/dev/event'' for SCO OpenServer file clones of the _/_d_e_v_/_e_v_e_n_t device, where _n is the minor device number of the file; or ``(socketpair: n)'' for a Solaris 2.6, 8, 9 or 10 UNIX domain socket, created by the _s_o_c_k_e_t_p_a_i_r(3N) network func‐ tion; 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 _s_h_u_t_d_o_w_n(2) function); 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; 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; or the association value, association index, endpoint value, local address, local port, remote address and remote port for Linux SCTP sockets; or ``protocol: '' followed by the Linux socket's protocol attribute. For dialects that support a ``namefs'' file system, allowing one file to be attached to another with _f_a_t_t_a_c_h(3C), _l_s_o_f 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 omit‐ ted if it already appears in the DEVICE column. _L_s_o_f may add two parenthetical notes to the NAME column for open Solaris 10 files: ``(?)'' if _l_s_o_f considers the path name of question‐ able accuracy; and ``(deleted)'' if the --XX option has been specified and _l_s_o_f detects the open file's path name has been deleted. Consult the _l_s_o_f FAQ (The FFAAQQ section gives its location.) for more informa‐ tion on these NAME column additions. LLOOCCKKSS _L_s_o_f 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. Moreover, when a process holds several byte level locks on a file, _l_s_o_f 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. Generally _l_s_o_f 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. _L_s_o_f has trouble reporting locks for some UNIX dialects. Consult the BBUUGGSS section of this manual page or the _l_s_o_f FAQ (The FFAAQQ section gives its location.) for more information. OOUUTTPPUUTT FFOORR OOTTHHEERR PPRROOGGRRAAMMSS When the --FF option is specified, _l_s_o_f produces output that is suitable for processing by another program - e.g, an _a_w_k or _P_e_r_l script, or a C program. 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. 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 com‐ mand, the process group IDentification (PGID) number, the task (thread) ID (TID), and the user ID (UID) number or login name. 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. When the NUL (000) field terminator has been selected with the 0 (zero) field identifier character, _l_s_o_f ends each process and file set with a NL (012) character. _L_s_o_f always produces one field, the PID (`p') field. All other fields may be declared optionally in the field identifier character list that follows the --FF option. When a field selection character identifies an item _l_s_o_f does not normally list - e.g., PPID, selected with --RR - spec‐ ification of the field character - e.g., ``--FFRR'' - also selects the listing of the item. 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, _l_s_o_f supports the --FF option; it selects the output of all fields with NL terminators (the --FF00 option pair selects the output of all fields with NUL terminators). For compatibility reasons neither --FF nor --FF00 select the raw device field. These are the fields that _l_s_o_f will produce. The single character listed first is the field identifier. a file access mode c process command name (all characters from proc or user structure) C file structure share count d file's device character code D file's major/minor device number (0x<hexadecimal>) f file descriptor (always selected) F file structure address (0x<hexadecimal>) G file flaGs (0x<hexadecimal>; names if ++ffgg follows) g process group ID i file's inode number K tasK ID k link count l file's lock status L process login name m marker between repeated output n file name, comment, Internet address N node identifier (ox<hexadecimal> o file's offset (decimal) p process ID (always selected) P protocol name r raw device number (0x<hexadecimal>) R parent process ID s file's size (decimal) S file's stream identification t file's type T TCP/TPI information, identified by prefixes (the `=' is part of the prefix): QR=<read queue size> QS=<send queue size> SO=<socket options and values> (not all dialects) SS=<socket states> (not all dialects) ST=<connection state> TF=<TCP flags and values> (not all dialects) WR=<window read size> (not all dialects) WW=<window write size> (not all dialects) (TCP/TPI information isn't reported for all supported UNIX dialects. The --hh or --?? help output for the --TT option will show what TCP/TPI reporting can be requested.) u process user ID z Solaris 10 and higher zone name Z SELinux security context (inhibited when SELinux is disabled) 0 use NUL field terminator character in place of NL 1-9 dialect-specific field identifiers (The output of --FF?? identifies the information to be found in dialect-specific fields.) You can get on-line help information on these characters and their descriptions by specifying the --FF?? option pair. (Escape the `?' char‐ acter as your shell requires.) Additional information on field content can be found in the OOUUTTPPUUTT section. As an example, ``--FF ppccffnn'' will select the process ID (`p'), command name (`c'), file descriptor (`f') and file name (`n') fields with an NL field terminator character; ``--FF ppccffnn00'' selects the same output with a NUL (000) field terminator character. _L_s_o_f 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 num‐ ber 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. Normally _l_s_o_f ends each field with a NL (012) character. The 0 (zero) field identifier character may be specified to change the field termi‐ nator character to a NUL (000). A NUL terminator may be easier to process with _x_a_r_g_s _(_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, _l_s_o_f ends each process and file set with a NL (012). Three aids to producing programs that can process _l_s_o_f field output are included in the _l_s_o_f distribution. The first is a C header file, _l_s_o_f___f_i_e_l_d_s_._h, that contains symbols for the field identification char‐ acters, indexes for storing them in a table, and explanation strings that may be compiled into programs. _L_s_o_f uses this header file. The second aid is a set of sample scripts that process field output, written in _a_w_k, _P_e_r_l 4, and _P_e_r_l 5. They're located in the _s_c_r_i_p_t_s subdirectory of the _l_s_o_f distribution. The third aid is the C library used for the _l_s_o_f test suite. The test suite is written in C and uses field output to validate the correct operation of _l_s_o_f. The library can be found in the _t_e_s_t_s_/_L_T_l_i_b_._c file of the _l_s_o_f distribution. The library uses the first aid, the _l_s_o_f___f_i_e_l_d_s_._h header file. BBLLOOCCKKSS AANNDD TTIIMMEEOOUUTTSS _L_s_o_f can be blocked by some kernel functions that it uses - _l_s_t_a_t(2), _r_e_a_d_l_i_n_k(2), and _s_t_a_t(2). These functions are stalled in the kernel, for example, when the hosts where mounted NFS file systems reside become inaccessible. _L_s_o_f attempts to break these blocks with timers and child processes, but the techniques are not wholly reliable. When _l_s_o_f does manage to break a block, it will report the break with an error message. The messages may be suppressed with the --tt and --ww options. The default timeout value may be displayed with the --hh or --?? option, and it may be changed with the --SS _[_t_] option. The minimum for _t is two seconds, but you should avoid small values, since slow system respon‐ siveness can cause short timeouts to expire unexpectedly and perhaps stop _l_s_o_f before it can produce any output. When _l_s_o_f 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. _L_s_o_f can also be directed to avoid the protection of timers and child processes when using the kernel functions that might block by specify‐ ing the --OO option. While this will allow _l_s_o_f to start up with less overhead, it exposes _l_s_o_f completely to the kernel situations that might block it. Use this option cautiously. AAVVOOIIDDIINNGG KKEERRNNEELL BBLLOOCCKKSS You can use the --bb option to tell _l_s_o_f to avoid using kernel functions that would block. Some cautions apply. First, using this option usually requires that your system supply alternate device numbers in place of the device numbers that _l_s_o_f would normally obtain with the _l_s_t_a_t(2) and _s_t_a_t(2) kernel functions. See the AALLTTEERRNNAATTEE DDEEVVIICCEE NNUUMMBBEERRSS section for more information on alternate device numbers. Second, you can't specify _n_a_m_e_s for _l_s_o_f to locate unless they're file system names. This is because _l_s_o_f needs to know the device and inode numbers of files listed with _n_a_m_e_s in the _l_s_o_f options, and the --bb option prevents _l_s_o_f from obtaining them. Moreover, since _l_s_o_f only has device numbers for the file systems that have alternates, its abil‐ ity to locate files on file systems depends completely on the avail‐ ability and accuracy of the alternates. If no alternates are avail‐ able, or if they're incorrect, _l_s_o_f won't be able to locate files on the named file systems. Third, if the names of your file system directories that _l_s_o_f obtains from your system's mount table are symbolic links, _l_s_o_f won't be able to resolve the links. This is because the --bb option causes _l_s_o_f to avoid the kernel _r_e_a_d_l_i_n_k(2) function it uses to resolve symbolic links. Finally, using the --bb option causes _l_s_o_f to issue warning messages when it needs to use the kernel functions that the --bb option directs it to avoid. You can suppress these messages by specifying the --ww option, but if you do, you won't see the alternate device numbers reported in the warning messages. AALLTTEERRNNAATTEE DDEEVVIICCEE NNUUMMBBEERRSS On some dialects, when _l_s_o_f has to break a block because it can't get information about a mounted file system via the _l_s_t_a_t(2) and _s_t_a_t(2) kernel functions, or because you specified the --bb option, _l_s_o_f can obtain some of the information it needs - the device number and possi‐ bly the file system type - from the system mount table. When that is possible, _l_s_o_f will report the device number it obtained. (You can suppress the report by specifying the --ww option.) You can assist this process if your mount table is supported with an _/_e_t_c_/_m_t_a_b or _/_e_t_c_/_m_n_t_t_a_b file that contains an options field by adding a ``dev=xxxx'' field for mount points that do not have one in their options strings. Note: you must be able to edit the file - i.e., some mount tables like recent Solaris /etc/mnttab or Linux /proc/mounts are read-only and can't be modified. You may also be able to supply device numbers using the ++mm and ++mm _m options, provided they are supported by your dialect. Check the output of _l_s_o_f_'_s --hh or --?? options to see if the ++mm and ++mm _m options are available. The ``xxxx'' portion of the field is the hexadecimal value of the file system's device number. (Consult the _s_t___d_e_v field of the output of the _l_s_t_a_t(2) and _s_t_a_t(2) functions for the appropriate values for your file systems.) Here's an example from a Sun Solaris 2.6 _/_e_t_c_/_m_n_t_t_a_b for a file system remotely mounted via NFS: nfs ignore,noquota,dev=2a40001 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 _l_s_o_f on one of its clients, _l_s_o_f probably won't be able to get output from the _l_s_t_a_t(2) and _s_t_a_t(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. Some dialects that do not use an ASCII _/_e_t_c_/_m_t_a_b or _/_e_t_c_/_m_n_t_t_a_b file for the mount table may still provide an alternative device number in their internal mount tables. This includes AIX, Apple Darwin, FreeBSD, NetBSD, OpenBSD, and Tru64 UNIX. _L_s_o_f knows how to obtain the alterna‐ tive device number for these dialects and uses it when its attempt to _l_s_t_a_t(2) or _s_t_a_t(2) the file system is blocked. If you're not sure your dialect supplies alternate device numbers for file systems from its mount table, use this _l_s_o_f incantation to see if it reports any alternate device numbers: lsof -b Look for standard error file warning messages that begin ``assuming "dev=xxxx" from ...''. KKEERRNNEELL NNAAMMEE CCAACCHHEE _L_s_o_f 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 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; some Solaris VxFS file system operations apparently don't use it, either.) _L_s_o_f reports the complete paths it finds in the NAME column. If _l_s_o_f 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. When _l_s_o_f is run in repeat mode - i.e., with the --rr 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 pro‐ cesses can cause the kernel to remove entries from its name cache and replace them with others. _L_s_o_f_'_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., 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, _l_s_o_f may find a reference to the wrong entry in the cache. The _l_s_o_f FAQ (The FFAAQQ section gives its location.) has more information on this situation. _L_s_o_f can report path name components for these dialects: FreeBSD HP-UX Linux NetBSD NEXTSTEP OpenBSD OPENSTEP SCO OpenServer SCO|Caldera UnixWare Solaris Tru64 UNIX _L_s_o_f can't report path name components for these dialects: AIX If you want to know why _l_s_o_f can't report path name components for some dialects, see the _l_s_o_f FAQ (The FFAAQQ section gives its location.) DDEEVVIICCEE CCAACCHHEE FFIILLEE Examining all members of the _/_d_e_v (or _/_d_e_v_i_c_e_s) node tree with _s_t_a_t(2) functions can be time consuming. What's more, the information that _l_s_o_f needs - device number, inode number, and path - rarely changes. Consequently, _l_s_o_f normally maintains an ASCII text file of cached _/_d_e_v (or _/_d_e_v_i_c_e_s) information (exception: the /proc-based Linux _l_s_o_f where it's not needed.) The local system administrator who builds _l_s_o_f can control the way the device cache file path is formed, selecting from these options: Path from the --DD option; Path from an environment variable; System-wide path; Personal path (the default); Personal path, modified by an environment variable. Consult the output of the --hh, --DD?? ,, 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 _l_s_o_f. The --DD?? 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. _L_s_o_f can detect that the current device cache file has been acciden‐ tally or maliciously modified by integrity checks, including the compu‐ tation and verification of a sixteen bit Cyclic Redundancy Check (CRC) sum on the file's contents. When _l_s_o_f 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 legiti‐ mately write. The path from which a _l_s_o_f 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 _l_s_o_f 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. If available, the --DDrr option will inhibit the writing of a new device cache file. (It's always available when specified without a path name argument.) When a new device is added to the system, the device cache file may need to be recreated. Since _l_s_o_f compares the mtime of the device cache file with the mtime and ctime of the _/_d_e_v (or _/_d_e_v_i_c_e_s) direc‐ tory, it usually detects that a new device has been added; in that case _l_s_o_f issues a warning message and attempts to rebuild the device cache file. Whenever _l_s_o_f 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. LLSSOOFF PPEERRMMIISSSSIIOONNSS TTHHAATT AAFFFFEECCTT DDEEVVIICCEE CCAACCHHEE FFIILLEE AACCCCEESSSS Two permissions of the _l_s_o_f executable affect its ability to access device cache files. The permissions are set by the local system admin‐ istrator when _l_s_o_f is installed. The first and rarer permission is setuid-root. It comes into effect when _l_s_o_f is executed; its effective UID is then root, while its real (i.e., that of the logged-on user) UID is not. The _l_s_o_f distribution recommends that versions for these dialects run setuid-root. HP-UX 11.11 and 11.23 Linux The second and more common permission is setgid. It comes into effect when the effective group IDentification number (GID) of the _l_s_o_f process is set to one that can access kernel memory devices - e.g., ``kmem'', ``sys'', or ``system''. An _l_s_o_f process that has setgid permission usually surrenders the per‐ mission after it has accessed the kernel memory devices. When it does that, _l_s_o_f can allow more liberal device cache path formations. The _l_s_o_f distribution recommends that versions for these dialects run set‐ gid and be allowed to surrender setgid permission. AIX 5.[12] and 5.3-ML1 Apple Darwin 7.x Power Macintosh systems FreeBSD 4.x, 4.1x, 5.x and [6789].x for x86-based systems FreeBSD 5.x and [6789].x for Alpha, AMD64 and Sparc64-based systems HP-UX 11.00 NetBSD 1.[456], 2.x and 3.x for Alpha, x86, and SPARC-based systems NEXTSTEP 3.[13] for NEXTSTEP architectures OpenBSD 2.[89] and 3.[0-9] for x86-based systems OPENSTEP 4.x SCO OpenServer Release 5.0.6 for x86-based systems SCO|Caldera UnixWare 7.1.4 for x86-based systems Solaris 2.6, 8, 9 and 10 Tru64 UNIX 5.1 (Note: _l_s_o_f for AIX 5L and above needs setuid-root permission if its --XX option is used.) _L_s_o_f for these dialects does not support a device cache, so the permis‐ sions given to the executable don't apply to the device cache file. Linux DDEEVVIICCEE CCAACCHHEE FFIILLEE PPAATTHH FFRROOMM TTHHEE --DD OOPPTTIIOONN The --DD 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 _l_s_o_f will use. When the --DD bb, rr, and uu functions are available, you can use them to request that the cache file be built in a specific location (bb[_p_a_t_h]); read but not rebuilt (rr[_p_a_t_h]); or read and rebuilt (uu[_p_a_t_h]). The bb, rr, and uu functions are restricted under some conditions. They are restricted when the _l_s_o_f process is setuid-root. The path specified with the rr function is always read-only, even when it is available. The bb, rr, and uu functions are also restricted when the _l_s_o_f process runs setgid and _l_s_o_f doesn't surrender the setgid permission. (See the LLSSOOFF PPEERRMMIISSSSIIOONNSS TTHHAATT AAFFFFEECCTT DDEEVVIICCEE CCAACCHHEE FFIILLEE AACCCCEESSSS section for a list of implementations that normally don't surrender their setgid per‐ mission.) A further --DD function, ii (for ignore), is always available. When available, the bb function tells _l_s_o_f to read device information from the kernel with the _s_t_a_t(2) function and build a device cache file at the indicated path. When available, the rr function tells _l_s_o_f to read the device cache file, but not update it. When a path argument accompanies --DDrr, it names the device cache file path. The rr function is always available when it is specified without a path name argument. If _l_s_o_f is not run‐ ning setuid-root and surrenders its setgid permission, a path name argument may accompany the rr function. When available, the uu function tells _l_s_o_f 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 _l_s_o_f process effective and real UIDs. DDEEVVIICCEE CCAACCHHEE PPAATTHH FFRROOMM AANN EENNVVIIRROONNMMEENNTT VVAARRIIAABBLLEE _L_s_o_f_'_s second choice for the device cache file is the contents of the LSOFDEVCACHE environment variable. It avoids this choice if the _l_s_o_f process is setuid-root, or the real UID of the process is root. A further restriction applies to a device cache file path taken from the LSOFDEVCACHE environment variable: _l_s_o_f will not write a device cache file to the path if the _l_s_o_f process doesn't surrender its setgid permission. (See the LLSSOOFF PPEERRMMIISSSSIIOONNSS TTHHAATT AAFFFFEECCTT DDEEVVIICCEE CCAACCHHEE FFIILLEE AACCCCEESSSS section for information on implementations that don't surrender their setgid permission.) The local system administrator can disable the use of the LSOFDEVCACHE environment variable or change its name when building _l_s_o_f. Consult the output of --DD?? for the environment variable's name. SSYYSSTTEEMM--WWIIDDEE DDEEVVIICCEE CCAACCHHEE PPAATTHH The local system administrator may choose to have a system-wide device cache file when building _l_s_o_f. That file will generally be constructed by a special system administration procedure when the system is booted or when the contents of _/_d_e_v or _/_d_e_v_i_c_e_s) changes. If defined, it is _l_s_o_f_'_s third device cache file path choice. You can tell that a system-wide device cache file is in effect for your local installation by examining the _l_s_o_f help option output - i.e., the output from the --hh or --?? option. _L_s_o_f will never write to the system-wide device cache file path by default. It must be explicitly named with a --DD 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). PPEERRSSOONNAALL DDEEVVIICCEE CCAACCHHEE PPAATTHH ((DDEEFFAAUULLTT)) The default device cache file path of the _l_s_o_f distribution is one recorded in the home directory of the real UID that executes _l_s_o_f. Added to the home directory is a second path component of the form _._l_s_o_f___h_o_s_t_n_a_m_e. This is _l_s_o_f_'_s fourth device cache file path choice, and is usually the default. If a system-wide device cache file path was defined when _l_s_o_f was built, this fourth choice will be applied when _l_s_o_f can't find the system-wide device cache file. This is the oonnllyy time _l_s_o_f uses two paths when reading the device cache file. The _h_o_s_t_n_a_m_e part of the second component is the base name of the exe‐ cuting host, as returned by _g_e_t_h_o_s_t_n_a_m_e(2). The base name is defined to be the characters preceding the first `.' in the _g_e_t_h_o_s_t_n_a_m_e(2) output, or all the _g_e_t_h_o_s_t_n_a_m_e(2) output if it contains no `.'. 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 dis‐ tinct real user ID on a given host that executes _l_s_o_f has a distinct device cache file. The _h_o_s_t_n_a_m_e 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. The personal device cache file path formed by this method represents a device cache file that _l_s_o_f will attempt to read, and will attempt to write should it not exist or should its contents be incorrect or out‐ dated. The --DDrr option without a path name argument will inhibit the writing of a new device cache file. The --DD?? option will list the format specification for constructing the personal device cache file. The conversions used in the format speci‐ fication are described in the _0_0_D_C_A_C_H_E file of the _l_s_o_f distribution. MMOODDIIFFIIEEDD PPEERRSSOONNAALL DDEEVVIICCEE CCAACCHHEE PPAATTHH If this option is defined by the local system administrator when _l_s_o_f is built, the LSOFPERSDCPATH environment variable contents may be used to add a component of the personal device cache file path. The LSOFPERSDCPATH variable contents are inserted in the path at the place marked by the local system administrator with the ``%p'' conver‐ sion in the HASPERSDC format specification of the dialect's _m_a_c_h_i_n_e_._h header file. (It's placed right after the home directory in the default _l_s_o_f distribution.) Thus, for example, if LSOFPERSDCPATH contains ``LSOF'', the home direc‐ tory is ``/Homes/abe'', the host name is ``lsof.itap.purdue.edu'', and the HASPERSDC format is the default (``%h/%p.lsof_%L''), the modified personal device cache file path is: /Homes/abe/LSOF/.lsof_vic The LSOFPERSDCPATH environment variable is ignored when the _l_s_o_f process is setuid-root or when the real UID of the process is root. _L_s_o_f will not write to a modified personal device cache file path if the _l_s_o_f process doesn't surrender setgid permission. (See the LLSSOOFF PPEERRMMIISSSSIIOONNSS TTHHAATT AAFFFFEECCTT DDEEVVIICCEE CCAACCHHEE FFIILLEE AACCCCEESSSS section for a list of implementations that normally don't surrender their setgid permission.) 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 _l_s_o_f doesn't surrender its setgid permission, you will have to allow _l_s_o_f to create device cache files at the standard per‐ sonal path and move them to your subdirectory with shell commands. The local system administrator may: disable this option when _l_s_o_f 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 --DD?? option for the environment variable's name and the HASPERSDC format specification. DDIIAAGGNNOOSSTTIICCSS Errors are identified with messages on the standard error file. _L_s_o_f 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 --VV option is specified, _l_s_o_f will indicate the search items it failed to list. 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. When _l_s_o_f cannot open access to _/_d_e_v (or _/_d_e_v_i_c_e_s) or one of its subdi‐ rectories, or get information on a file in them with _s_t_a_t(2), it issues a warning message and continues. That _l_s_o_f will issue warning messages about inaccessible files in _/_d_e_v (or _/_d_e_v_i_c_e_s) is indicated in its help output - requested with the --hh or >B -? options - with the message: Inaccessible /dev warnings are enabled. The warning message may be suppressed with the --ww option. It may also have been suppressed by the system administrator when _l_s_o_f was compiled by the setting of the WARNDEVACCESS definition. In this case, the out‐ put from the help options will include the message: Inaccessible /dev warnings are disabled. Inaccessible device warning messages usually disappear after _l_s_o_f has created a working device cache file. EEXXAAMMPPLLEESS For a more extensive set of examples, documented more fully, see the _0_0_Q_U_I_C_K_S_T_A_R_T file of the _l_s_o_f distribution. To list all open files, use: lsof To list all open Internet, x.25 (HP-UX), and UNIX domain files, use: lsof -i -U To list all open IPv4 network files in use by the process whose PID is 1234, use: lsof -i 4 -a -p 1234 Presuming the UNIX dialect supports IPv6, to list only open IPv6 net‐ work files, use: lsof -i 6 To list all files using any protocol on ports 513, 514, or 515 of host wonderland.cc.purdue.edu, use: lsof -i @wonderland.cc.purdue.edu:513-515 To list all files using any protocol on any port of mace.cc.purdue.edu (cc.purdue.edu is the default domain), use: lsof -i @mace To list all open files for login name ``abe'', or user ID 1234, or process 456, or process 123, or process 789, use: lsof -p 456,123,789 -u 1234,abe To list all open files on device /dev/hd4, use: lsof /dev/hd4 To find the process that has /u/abe/foo open, use: lsof /u/abe/foo To send a SIGHUP to the processes that have /u/abe/bar open, use: kill -HUP `lsof -t /u/abe/bar` To find any open file, including an open UNIX domain socket file, with the name _/_d_e_v_/_l_o_g, use: lsof /dev/log To find processes with open files on the NFS file system named _/_n_f_s_/_m_o_u_n_t_/_p_o_i_n_t whose server is inaccessible, and presuming your mount table supplies the device number for _/_n_f_s_/_m_o_u_n_t_/_p_o_i_n_t, use: lsof -b /nfs/mount/point To do the preceding search with warning messages suppressed, use: lsof -bw /nfs/mount/point To ignore the device cache file, use: lsof -Di 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: lsof -FpcfDi To list the files at descriptors 1 and 3 of every process running the _l_s_o_f command for login ID ``abe'' every 10 seconds, use: lsof -c lsof -a -d 1 -d 3 -u abe -r10 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 --cc _c option: lsof -c /^..o.$/i -a -d cwd To find an IP version 4 socket file by its associated numeric dot-form address, use: lsof -i@128.210.15.17 To find an IP version 6 socket file (when the UNIX dialect supports IPv6) by its associated numeric colon-form address, use: lsof -i@[0:1:2:3:4:5:6:7] 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: lsof -i@[::1] To obtain a repeat mode marker line that contains the current time, use: lsof -rm====%T==== To add spaces to the previous marker line, use: lsof -r "m==== %T ====" BBUUGGSS Since _l_s_o_f reads kernel memory in its search for open files, rapid changes in kernel memory may produce unpredictable results. When a file has multiple record locks, the lock status character (fol‐ lowing 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. _L_s_o_f can't search for files with restrictive access permissions by _n_a_m_e 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. The display of the destination address of a raw socket (e.g., for _p_i_n_g) depends on the UNIX operating system. Some dialects store the destina‐ tion address in the raw socket's protocol control block, some do not. _L_s_o_f can't always represent Solaris device numbers in the same way that _l_s(1) does. For example, the major and minor device numbers that the _l_s_t_a_t(2) and _s_t_a_t(2) functions report for the directory on which CD-ROM files are mounted (typically _/_c_d_r_o_m) are not the same as the ones that it reports for the device on which CD-ROM files are mounted (typically _/_d_e_v_/_s_r_0). (_L_s_o_f reports the directory numbers.) The support for _/_p_r_o_c file systems is available only for BSD and Tru64 UNIX dialects, Linux, and dialects derived from SYSV R4 - e.g., Free‐ BSD, NetBSD, OpenBSD, Solaris, UnixWare. Some _/_p_r_o_c file items - device number, inode number, and file size - are unavailable in some dialects. Searching for files in a _/_p_r_o_c file system may require that the full path name be specified. No text (ttxxtt) 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 mmeemm descriptors. _L_s_o_f can't search for Tru64 UNIX named pipes by name, because their kernel implementation of lstat(2) returns an improper device number for a named pipe. _L_s_o_f 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 _l_s_o_f FAQ (The FFAAQQ section gives its location.) for details. The AIX SMT file type is a fabrication. It's made up for file struc‐ tures whose type (15) isn't defined in the AIX _/_u_s_r_/_i_n_c_l_u_d_e_/_s_y_s_/_f_i_l_e_._h header file. One way to create such file structures is to run X clients with the DISPLAY variable set to ``:0.0''. The ++||--ff_[_c_f_g_G_n_] option is not supported under /proc-based Linux _l_s_o_f, because it doesn't read kernel structures from kernel memory. EENNVVIIRROONNMMEENNTT _L_s_o_f may access these environment variables. LANG defines a language locale. See _s_e_t_l_o_c_a_l_e(3) for the names of other variables that can be used in place of LANG - e.g., LC_ALL, LC_TYPE, etc. LSOFDEVCACHE defines the path to a device cache file. See the DDEEVVIICCEE CCAACCHHEE PPAATTHH FFRROOMM AANN EENNVVIIRROONNMMEENNTT VVAARRIIAABBLLEE sec‐ tion for more information. LSOFPERSDCPATH defines the middle component of a modified personal device cache file path. See the MMOODDIIFFIIEEDD PPEERRSSOONNAALL DDEEVVIICCEE CCAACCHHEE PPAATTHH section for more information. FFAAQQ Frequently-asked questions and their answers (an FAQ) are available in the _0_0_F_A_Q file of the _l_s_o_f distribution. That file is also available via anonymous ftp from _l_s_o_f_._i_t_a_p_._p_u_r_d_u_e_._e_d_u at _p_u_b_/_t_o_o_l_s_/_u_n_i_x_/_l_s_o_fFAQ_. The URL is: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/FAQ FFIILLEESS _/_d_e_v_/_k_m_e_m kernel virtual memory device _/_d_e_v_/_m_e_m physical memory device _/_d_e_v_/_s_w_a_p system paging device _._l_s_o_f___h_o_s_t_n_a_m_e _l_s_o_f_'_s device cache file (The suffix, _h_o_s_t_n_a_m_e, is the first component of the host's name returned by _g_e_t_h_o_s_t_n_a_m_e(2).) AAUUTTHHOORRSS _L_s_o_f was written by Victor A.Abell <abe@purdue.edu> of Purdue Univer‐ sity. Many others have contributed to _l_s_o_f. They're listed in the _0_0_C_R_E_D_I_T_S file of the _l_s_o_f distribution. DDIISSTTRRIIBBUUTTIIOONN The latest distribution of _l_s_o_f is available via anonymous ftp from the host _l_s_o_f_._i_t_a_p_._p_u_r_d_u_e_._e_d_u. You'll find the _l_s_o_f distribution in the _p_u_b_/_t_o_o_l_s_/_u_n_i_x_/_l_s_o_f directory. You can also use this URL: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof _L_s_o_f is also mirrored elsewhere. When you access _l_s_o_f_._i_t_a_p_._p_u_r_d_u_e_._e_d_u and change to its _p_u_b_/_t_o_o_l_s_/_u_n_i_x_/_l_s_o_f directory, you'll be given a list of some mirror sites. The _p_u_b_/_t_o_o_l_s_/_u_n_i_x_/_l_s_o_f directory also contains a more complete list in its _m_i_r_r_o_r_s file. Use mirrors with caution - not all mirrors always have the latest _l_s_o_f revision. Some pre-compiled _L_s_o_f executables are available on _l_s_o_f_._i_t_a_p_._p_u_r_‐ _d_u_e_._e_d_u, 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 exe‐ cutable, please read the cautions that appear in the README files of the _p_u_b_/_t_o_o_l_s_/_u_n_i_x_/_l_s_o_f_/_b_i_n_a_r_i_e_s subdirectories and in the 00* files of the distribution. More information on the _l_s_o_f distribution can be found in its _R_E_A_D_M_E_._l_s_o_f___<_v_e_r_s_i_o_n_> file. If you intend to get the _l_s_o_f distribution and build it, please read _R_E_A_D_M_E_._l_s_o_f___<_v_e_r_s_i_o_n_> and the other 00* files of the distribution before sending questions to the author. SSEEEE AALLSSOO Not all the following manual pages may exist in every UNIX dialect to which _l_s_o_f has been ported. access(2), awk(1), crash(1), fattach(3C), ff(1), fstat(8), fuser(1), gethostname(2), isprint(3), kill(1), localtime(3), lstat(2), mod‐ load(8), mount(8), netstat(1), ofiles(8L), perl(1), ps(1), readlink(2), setlocale(3), stat(2), strftime(3), time(2), uname(1). Revision-4.89 LSOF(8)
importlib.reload(cdt_reader)
hello,world
<module 'cdt_reader' from '/home/bms270/BMS270_2018/cdt_reader.py'>
cdt_reader.__file__
'/home/bms270/BMS270_2018/cdt_reader.py'
!ls *.pyc
ls: cannot access '*.pyc': No such file or directory
(colnames,genes,annotations,data2) = cdt_reader.parse_cdt("supp2data.cdt",0.)
data2[0][:10]
[0.33, -0.17, 0.04, -0.07, -0.09, -0.12, -0.03, -0.2, -0.06, -0.06]
small_data2 = data2[:10]
import stats
stats.pearson(small_data2[0],small_data2[1])
0.12164363213592637
%time
print("hi")
print("there")
CPU times: user 0 ns, sys: 0 ns, total: 0 ns Wall time: 6.2 µs hi there
for i in small_data2:
print(i)
break
[0.33, -0.17, 0.04, -0.07, -0.09, -0.12, -0.03, -0.2, -0.06, -0.06, -0.14, -0.18, -0.06, -0.25, 0.06, -0.12, 0.25, 0.43, 0.21, -0.04, -0.15, -0.04, 0.21, -0.14, -0.03, -0.07, -0.36, -0.14, -0.42, -0.34, -0.23, -0.17, 0.23, 0.3, 0.41, -0.07, -0.23, -0.12, 0.16, 0.74, 0.14, -0.49, -0.32, 0.19, 0.23, 0.24, 0.28, 1.13, -0.12, 0.1, 0.0, 0.66, 0.62, 0.08, 0.62, 0.43, 0.5, -0.25, -0.51, -0.67, 0.21, -0.74, -0.36, -0.01, 0.38, 0.15, -0.22, -0.09, 0.33, 0.08, 0.39, -0.17, 0.23, 0.2, 0.2, -0.17, -0.69, 0.14, -0.27]
fp = open("myfile.txt","w")
fp.write("Hello, world")
12
fp.write("A second line")
13
fp.close()
print(open("myfile.txt").read())
Hello, worldA second line
fp = open("myfile.txt","w")
fp.write("Hello, world\n")
fp.write("A second line\n")
fp.close()
print(open("myfile.txt").read())
Hello, world A second line
open("myfile.txt").read()
'Hello, world\nA second line\n'
fp = open("myfile.txt","w")
fp.write("Some log text")
fp.flush()
open("myfile.txt").read()
'Some log text'
fp.close()
"\t".join(["hello","world"])
'hello\tworld'
"\t".join([1,2,3])
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-43-d6d3ec56d3d0> in <module>() ----> 1 "\t".join([1,2,3]) TypeError: sequence item 0: expected str instance, int found
s = []
for i in [1,2,3]:
s.append(str(i))
"\t".join(s)
'1\t2\t3'
from csv import reader,writer,excel_tab
fin = reader(open("supp2data.cdt"), dialect=excel_tab)
for i in fin:
print(i)
break
['ORF', 'NAME', 'alpha 0', 'alpha 7', 'alpha 14', 'alpha 21', 'alpha 28', 'alpha 35', 'alpha 42', 'alpha 49', 'alpha 56', 'alpha 63', 'alpha 70', 'alpha 77', 'alpha 84', 'alpha 91', 'alpha 98', 'alpha 105', 'alpha 112', 'alpha 119', 'Elu 0', 'Elu 30', 'Elu 60', 'Elu 90', 'Elu 120', 'Elu 150', 'Elu 180', 'Elu 210', 'Elu 240', 'Elu 270', 'Elu 300', 'Elu 330', 'Elu 360', 'Elu 390', 'cdc15 10', 'cdc15 30', 'cdc15 50', 'cdc15 70', 'cdc15 90', 'cdc15 110', 'cdc15 130', 'cdc15 150', 'cdc15 170', 'cdc15 190', 'cdc15 210', 'cdc15 230', 'cdc15 250', 'cdc15 270', 'cdc15 290', 'spo 0', 'spo 2', 'spo 5', 'spo 7', 'spo 9', 'spo 11', 'spo5 2', 'spo5 7', 'spo5 11', 'spo- early', 'spo- mid', 'heat 0', 'heat 10', 'heat 20', 'heat 40', 'heat 80', 'heat 160', 'dtt 15', 'dtt 30', 'dtt 60', 'dtt 120', 'cold 0', 'cold 20', 'cold 40', 'cold 160', 'diau a', 'diau b', 'diau c', 'diau d', 'diau e', 'diau f', 'diau g']
fout = writer(open("example.csv","w"))
for i in small_data2:
fout.writerow(i)
del fout
print(open("example.csv").read())
0.33,-0.17,0.04,-0.07,-0.09,-0.12,-0.03,-0.2,-0.06,-0.06,-0.14,-0.18,-0.06,-0.25,0.06,-0.12,0.25,0.43,0.21,-0.04,-0.15,-0.04,0.21,-0.14,-0.03,-0.07,-0.36,-0.14,-0.42,-0.34,-0.23,-0.17,0.23,0.3,0.41,-0.07,-0.23,-0.12,0.16,0.74,0.14,-0.49,-0.32,0.19,0.23,0.24,0.28,1.13,-0.12,0.1,0.0,0.66,0.62,0.08,0.62,0.43,0.5,-0.25,-0.51,-0.67,0.21,-0.74,-0.36,-0.01,0.38,0.15,-0.22,-0.09,0.33,0.08,0.39,-0.17,0.23,0.2,0.2,-0.17,-0.69,0.14,-0.27 -0.64,-0.38,-0.32,-0.29,-0.22,-0.01,-0.32,-0.27,-0.51,-0.67,-0.62,-0.58,-0.38,-0.94,-0.34,-0.92,-0.15,0.03,0.16,-0.34,-0.32,-0.34,-0.12,-0.34,-0.27,-0.15,-0.15,-0.51,-0.3,-0.25,-0.12,-0.4,0.98,0.99,0.25,0.15,0.08,0.23,0.18,-0.29,-0.45,0.01,-0.34,-1.12,-0.54,-0.94,-1.09,-0.45,-0.23,-0.36,0.08,0.28,0.18,-0.12,0.0,0.25,-0.22,-0.04,-0.25,0.04,-0.03,-0.07,-0.04,0.73,-0.06,0.54,-0.09,-0.29,-0.1,0.36,-0.2,-0.34,-0.14,-0.09,0.06,-0.17,0.04,-0.97,-1.79 -0.23,0.19,-0.36,0.14,-0.4,0.16,-0.09,-0.12,-0.14,-0.14,-0.38,-0.22,0.12,-0.43,-0.42,-0.45,-0.17,-0.27,0.29,-0.09,0.4,-0.1,0.46,0.15,-0.17,-0.18,-0.07,-0.34,0.3,-0.12,-0.06,-0.17,0.07,0.38,0.34,0.0,-0.15,-0.2,0.19,0.37,0.24,-0.07,0.0,0.24,0.45,0.23,0.5,-0.07,0.0,0.66,0.94,0.46,0.06,-0.18,0.39,-0.18,0.16,0.55,-0.06,-0.94,0.21,-0.71,-0.86,-0.45,0.42,1.04,0.65,0.53,-0.47,0.21,-0.29,-0.36,-0.1,-0.29,-0.18,-0.34,-0.47,-0.43,-1.06 -0.69,-0.89,-0.74,-0.56,-0.64,-0.18,-0.42,-0.34,0.0,0.01,-0.1,-0.17,-0.12,-0.43,-0.18,0.06,-0.2,-0.22,-0.04,0.34,0.42,-0.04,-0.14,0.15,0.26,0.4,0.24,0.25,0.37,-0.04,-0.27,0.11,-0.15,-0.07,0.06,0.23,0.07,-0.12,-0.12,0.0,0.04,0.25,0.1,0.3,-0.12,-0.23,-0.12,0.19,0.24,0.0,0.41,0.36,0.98,-0.04,0.18,0.24,0.44,0.32,-0.22,-0.71,-0.34,-0.45,-0.3,-0.45,0.58,-0.22,0.1,0.19,-0.32,-0.01,-0.29,0.31,0.21,0.07,0.18,-0.14,-0.2,-0.43,-1.51 0.04,0.01,-0.81,0.0,-0.3,0.49,0.08,0.19,-0.03,-0.32,-0.34,-0.22,-0.03,-0.06,0.06,0.07,0.1,0.03,-0.18,-0.2,-0.12,0.16,-0.17,0.1,-0.14,-0.01,-0.15,0.04,0.23,-0.04,0.07,0.06,0.7,0.36,0.37,0.3,-0.04,0.19,-0.45,0.21,-1.12,-0.04,0.3,0.88,-0.49,-0.23,-0.04,-0.2,0.45,0.52,0.62,0.48,0.65,-0.14,-0.14,-0.49,-0.04,0.14,-0.1,-0.2,0.01,-0.4,-0.23,-0.04,0.25,-0.27,0.1,0.1,-0.2,0.28,-0.17,0.26,0.07,-0.17,0.0,-0.1,-0.23,-0.51,-1.4 0.11,0.32,0.03,0.32,0.03,-0.12,0.01,-0.36,-0.01,-0.17,-0.22,-0.22,-0.1,-0.51,-0.25,-0.38,-0.27,-0.2,-0.45,0.82,-0.12,-0.43,-0.1,-0.1,-0.64,0.08,0.1,0.2,0.2,0.16,0.2,0.2,-0.2,-0.14,0.19,0.15,0.3,0.14,0.0,-0.14,-0.18,0.01,0.03,-0.38,0.2,0.19,0.41,-0.4,-0.07,0.0,0.74,-0.09,0.38,-0.64,-0.04,-0.1,-0.23,-0.56,-0.25,-1.0,-0.25,-0.62,-0.64,-0.36,-0.3,-0.12,0.16,-0.34,-0.17,0.39,-0.06,-0.67,0.04,-0.22,-0.12,-0.15,-0.67,-0.38,-0.27 -0.47,1.0,-0.51,-0.25,-0.71,-0.22,-0.3,-0.36,-0.1,0.08,0.0,-0.27,-0.23,-0.45,-0.32,-0.17,-0.56,-0.01,0.44,0.26,0.4,0.12,-0.03,0.07,0.16,0.58,0.33,0.2,0.14,0.2,0.34,0.21,0.82,0.52,0.48,0.77,0.14,0.55,0.37,0.25,0.29,0.18,0.07,0.73,0.37,-0.01,0.24,0.25,-0.1,0.11,0.21,0.08,0.12,-0.14,0.39,0.28,-0.1,-0.4,0.43,-0.1,-0.01,-0.2,-0.18,-0.1,-0.22,-0.43,-0.17,0.04,-0.06,0.24,-0.04,-0.4,-0.38,-0.56,0.11,-0.27,-0.58,0.48,0.19 -0.25,0.26,0.01,-0.06,-0.42,-0.07,-0.3,-0.18,-0.1,-0.27,-0.29,-0.04,0.04,-0.18,-0.1,-0.03,-0.4,0.03,0.32,-0.09,0.38,-0.38,-0.29,-0.56,-0.36,0.03,0.06,-0.04,-0.01,0.19,0.21,0.26,0.24,0.03,0.52,0.5,0.2,0.0,-0.15,0.08,0.14,-0.09,0.23,0.4,0.34,0.29,0.58,0.1,-0.54,-0.34,0.62,0.37,0.36,-0.56,0.93,0.33,0.26,0.04,0.24,0.96,0.28,0.34,0.58,0.86,0.06,-0.17,0.32,0.18,0.12,0.29,-0.14,-1.18,-0.23,-0.47,0.32,0.04,-0.06,0.63,0.3 -0.58,-0.29,-0.45,-0.15,-0.86,-0.36,-0.54,-0.47,-0.29,0.08,-0.58,-0.43,-0.38,-0.36,-0.43,-0.3,-0.32,-0.22,0.08,0.32,0.03,0.16,-0.09,-0.14,0.0,0.08,-0.07,0.11,-0.23,-0.12,-0.01,0.15,0.56,0.46,0.18,0.36,0.42,0.24,0.34,0.42,0.86,0.7,0.15,-0.03,0.19,0.14,0.18,0.03,-0.32,0.69,1.56,1.14,1.15,-0.86,0.74,0.28,0.79,0.96,1.29,0.08,0.44,0.04,0.32,0.46,-0.3,-0.2,-0.51,-0.09,-0.07,2.46,0.23,0.37,-0.15,-0.42,-0.14,-0.64,-0.62,0.69,1.09 -0.36,-0.17,-0.22,-0.34,-0.36,0.03,-0.2,-0.42,-0.15,0.06,-0.2,-0.1,-0.15,-0.4,-0.3,-0.14,-0.64,-0.15,-0.03,0.1,-1.03,-0.23,-0.23,-0.18,-0.17,0.1,-0.03,0.11,0.0,0.07,-0.03,0.26,-0.04,0.75,0.7,0.14,-0.06,-0.2,0.07,0.44,0.37,-0.01,0.15,0.03,-0.51,-0.49,-0.2,-0.23,-0.64,0.11,0.89,0.52,0.87,-0.86,0.57,0.19,-0.27,-0.22,0.39,0.42,0.55,0.46,0.37,-0.06,-0.56,0.07,0.1,0.19,-0.54,0.0,-0.14,-0.14,-0.15,-0.18,0.33,0.16,-0.3,0.49,0.44
%less example.csv
print("%3.2f" % 7)
7.00
print("%3.2f" % 7,end="")
7.00
for i in range(3):
print("%3.2f" % 7,end="")
7.007.007.00
i = "GENE1"
j = "TYR1"
k = ["2","3","4"]
row = [i,j]+k
row
['GENE1', 'TYR1', '2', '3', '4']