请输入您要查询的百科知识:

 

词条 Lsof
释义

  1. Examples

  2. Lsof output

  3. See also

  4. References

  5. External links

{{refimprove|date=January 2015}}{{lowercase|title=lsof}}{{infobox software
| name = lsof
| logo =
| screenshot =
| caption =
| collapsible =
| author =
| developer = Victor A. Abell [1]
| released =
| discontinued =
| latest release version = 4.89
| latest release date = {{start date and age|2015|06|07|df=yes}} [2]
| latest preview version = 4.91
| latest preview date =
| status =
| programming language =C
| operating system =Linux, FreeBSD, OS X, Solaris
| platform =Cross-platform
| size =
| language =
| genre =
| license = BSD license-compatible[3]
| website = {{URL|people.freebsd.org/~abe/}}
| frequently updated =
}}lsof is a command meaning "list open files", which is used in many Unix-like systems to report a list of all open files and the processes that opened them. This open source utility was developed and supported by Victor A. Abell, the retired Associate Director of the Purdue University Computing Center. It works in and supports several Unix flavors.[4]

Examples

Open files in the system include disk files, named pipes, network sockets and devices opened by all processes. One use for this command is when a disk cannot be unmounted because (unspecified) files are in use. The listing of open files can be consulted (suitably filtered if necessary) to identify the process that is using the files.

  1. lsof /var

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME

syslogd 350 root 5w VREG 222,5 0 440818 /var/adm/messages

syslogd 350 root 6w VREG 222,5 339098 6248 /var/log/syslog

cron 353 root cwd VDIR 222,5 512 254550 /var -- atjobs

To view the port associated with a daemon:

  1. lsof -i -n -P | grep sendmail

sendmail 31649 root 4u IPv4 521738 TCP *:25 (LISTEN)

From the above one can see that "sendmail" is listening on its standard port of "25".

-i
Lists IP sockets.
-n
Do not resolve hostnames (no DNS).
-P
Do not resolve port names (list port number instead of its name).

One can also list Unix Sockets by using lsof -U.

Lsof output

The lsof output describes:

  • the identification number of the process (PID) that has opened the file;
  • the process group identification number (PGID) of the process (optional);
  • the process identification number of the parent process (PPID) (optional);
  • the command the process is executing;
  • the owner of the process;
  • for all files in use by the process, including the executing text file and the shared libraries it is using:
    • the file descriptor number of the file, if applicable;
    • the file's access mode;
    • the file's lock status;
    • the file's device numbers;
    • the file's inode number;
    • the file's size or offset;
    • the name of the file system containing the file;
    • any available components of the file's path name;
    • the names of the file's stream components;
    • the file's local and remote network addresses;
    • the TLI network (typically UDP) state of the file;
    • the TCP state, read queue length, and write queue length of the file;
    • the file's TCP window read and write lengths (Solaris only); and
    • other file or dialect-specific values.

See also

  • fuser (Unix)
  • stat (Unix)
  • netstat
  • strace
  • List of Unix commands

References

1. ^{{cite web |url=ftp://lsof.itap.purdue.edu/pub/Victor_A_Abell.gpg |title=PGP public key |accessdate=2013-01-15}}
2. ^{{cite web |url=ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/lsof.tar.bz2.sig |title=4.89 PGP signature |date=2015-05-07 |accessdate=2015-05-07}}
3. ^lsof FAQ, 1.9 Is there an lsof license?
4. ^{{citation|title=Unix Network Programming: the Sockets networking API |author1=W. Richard Stevens |author2=Bill Fenner |author3=Andrew M. Rudoff |year= 2003|publisher=Addison-Wesley Professional|url= https://books.google.com/books?id=ptSC4LpwGA0C&pg=RA1-PA897&lpg=RA1-PA897&dq=Lsof |isbn=978-0-13-141155-5}}

External links

  • {{Official website}}
  • [https://lists.purdue.edu/mailman/listinfo/lsof-l lsof-l mailing list]
  • mirror of sources
  • {{man|8|lsof|die.net}}
  • {{man|8|lsof|Darwin}}
  • Using lsof
  • Lsof FAQ
  • Sam Nelson's [https://web.archive.org/web/20070509052951/http://www.unix.ms/pcp/ PCP] script, an alternative to "lsof -i" for Solaris.
  • Glsof is two separate utilities (Queries and Filemonitor) based on lsof.
  • Sloth is a macOS graphical interface for lsof
  • [https://netadmintools.com/html/lsof.man.html Manpage of LSOF]
{{Unix commands}}

1 : Unix file system-related software

随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/9/25 18:30:58