# Lsof

> Mediated Wiki article. Canonical URL: https://mediated.wiki/source/Lsof
> Markdown URL: https://mediated.wiki/source/Lsof.md
> Source: https://en.wikipedia.org/wiki/Lsof
> Source revision: 1320327047
> License: Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)

Computing command

lsof Original author Victor A. Abell Release 1991; 35 years ago (1991)[1] Stable release 4.99.7[2] / 16 June 2026; 10 days ago (16 June 2026) Written in C Operating system Linux, FreeBSD, macOS, Solaris, NetBSD and OpenBSD Platform Cross-platform License BSD license-compatible[3] Website lsof.readthedocs.io Repository github.com/lsof-org/lsof

**lsof** is a command meaning "list open files", which is used in many [Unix-like](/source/Unix-like) systems to report a list of all open files and the processes that opened them. This [open source](/source/Open-source_software) utility was developed and supported by Victor A. Abell, the retired associate director of the [Purdue University](/source/Purdue_University) Computing Center. It works in and supports several Unix flavors.[4]

A replacement for Linux, **lsfd**, is included in [util-linux](/source/Util-linux).[5]

## History

In 1985, Cliff Spencer publishes the **ofiles** command. Its [man page](/source/Man_page) says: "ofiles – who has a file open [...] displays the owner and id of any process accessing a specified device". Spencer compiled it for [4.2BSD](/source/4.2BSD) and [ULTRIX](/source/ULTRIX).[6] Moreover, in the [newsgroup](/source/Newsgroup) net.unix-wizards, he further remarks:[7]

With all the chatter about dismounting active file systems, I have posted my program to indicate who is using a particular filesystem, "ofiles" to net.sources.

In 1988, the command **fstat** ("file status") appears as part of the [4.3BSD-Tahoe](/source/4.3BSD-Tahoe) release. Its man page says:[8]

*fstat* identifies open files. A file is considered open if a process has it open, if it is the working directory for a process, or if it is an active pure text file. If no options are specified, *fstat* reports on all open files.

In 1989, in comp.sources.unix, Vic Abell publishes ports of the ofiles and fstat commands from [4.3BSD-Tahoe](/source/4.3BSD-Tahoe) to "[DYNIX](/source/DYNIX) 3.0.1[24] for Sequent Symmetry and Balance, [SunOS](/source/SunOS) 4.0 and [ULTRIX](/source/ULTRIX) 2.2".[9][10] Various people had evolved and ported ofiles over the years. Abell contrasted the commands as follows:[10]

Fstat is similar to the ofiles program which I recently submitted. Like ofiles, fstat identifies open files. It's orientation differs slightly from that of ofiles: ofiles starts with a file name and paws through the proc and user structures to identify the file; fstat reads all the proc and user structures, displaying information in all files, optionally applying a few filters to the output (including a single file name filter.)

In combination with netstat -aA and grep, fstat will identify the process associated with a network connection, just as will ofiles.

In 1991, Vic Abell publishes lsof version 1.0 to comp.sources.unix. He notes:[1]

Lsof (for LiSt Open Files) lists files opened by processes on selected Unix systems. It is my answer to those who regularly ask me when I am going to make fstat (comp.sources.unix volume 18, number 107) or ofiles (volume 18, number 57) available on [SunOS](/source/SunOS) 4.1.1 or the like.

Lsof is a complete redesign of the fstat/ofiles series, based on the SunOS vnode model. Thus, it has been tested on [AIX](/source/AIX) 3.1.[357], [HP-UX](/source/HP-UX) [78].x, [NeXTStep](/source/NeXTStep) 2.[01], Sequent [Dynix](/source/Dynix) 3.0.12 and 3.1.2, and [Sunos](/source/Sunos) 4.1 and 4.1.1. Using available kernel access methods, such as nlist() and kvm_read(), lsof reads process table entries, user areas and file pointers to reach the underlying structures that describe files opened by processes.

In 2018, Vic Abbell publishes lsof version 4.92. The same year, he initiates the transfer of responsibility. He writes:[11]

I will reach 80 years of age later this year and I think it's time for me to end my work on general lsof revision releases.

The lsof code is put on GitHub and maintenance is transferred.[11][12]

## Examples

Open files in the system include disk files, [named pipes](/source/Named_pipe), network [sockets](/source/Internet_socket) 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.

# 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:

# 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.

For a complete list of options, see the Lsof(8) Linux manual page.[13]

## See also

- [fuser (Unix)](/source/Fuser_(Unix))

- [stat (Unix)](/source/Stat_(Unix))

- [netstat](/source/Netstat)

- [strace](/source/Strace)

- [List of Unix commands](/source/List_of_Unix_commands)

## References

1. ^ [***a***](#cite_ref-lsofv1_1-0) [***b***](#cite_ref-lsofv1_1-1) ["v25i002: lsof - a successor to fstat and ofiles"](https://sources.vsta.org/comp.sources.unix/volume25/lsof). comp.sources.unix. [Archived](https://web.archive.org/web/20230110165833/https://sources.vsta.org/comp.sources.unix/volume25/lsof) from the original on 2023-01-10. Retrieved 2023-04-13.

1. **[^](#cite_ref-wikidata-a36b09e17cbd96d23c628568e02193ad49bb0272-v20_2-0)** lsof-org. ["Release lsof 4.99.7 · lsof-org/lsof"](https://github.com/lsof-org/lsof/releases/tag/4.99.7). Retrieved 17 June 2026.

1. **[^](#cite_ref-3)** [lsof FAQ, 1.9 Is there an lsof license?](ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/FAQ)[*[dead link](https://en.wikipedia.org/wiki/Wikipedia:Link_rot)*]

1. **[^](#cite_ref-4)** W. Richard Stevens; Bill Fenner; Andrew M. Rudoff (2003), [*Unix Network Programming: the Sockets networking API*](https://books.google.com/books?id=ptSC4LpwGA0C&dq=Lsof&pg=RA1-PA897), Addison-Wesley Professional, [ISBN](/source/ISBN_(identifier)) [978-0-13-141155-5](https://en.wikipedia.org/wiki/Special:BookSources/978-0-13-141155-5)

1. **[^](#cite_ref-5)** ["RFC: lsfd, a brand new Linux specific replacement for lsof #1418"](https://github.com/util-linux/util-linux/pull/1418). [Archived](https://web.archive.org/web/20230219081423/https://github.com/util-linux/util-linux/pull/1418) from the original on 2023-02-19. Retrieved 2023-02-19.

1. **[^](#cite_ref-6)** Spencer, Cliff. ["ofiles(8)"](https://groups.google.com/g/net.sources/c/L82MvsQrnoA/m/LOADevFckCkJ). *groups.google.com*. net.sources. [Archived](https://web.archive.org/web/20230413052716/https://groups.google.com/g/net.sources/c/L82MvsQrnoA/m/LOADevFckCkJ) from the original on 2023-04-13. Retrieved 2023-04-13.

1. **[^](#cite_ref-7)** Spencer, Cliff. [""ofiles" posted to net.sources"](https://groups.google.com/g/net.unix-wizards/c/UyTm4kUMMDE/m/NzIh78IWdXkJ). *groups.google.com*. net.unix-wizards. [Archived](https://web.archive.org/web/20230413052718/https://groups.google.com/g/net.unix-wizards/c/UyTm4kUMMDE/m/NzIh78IWdXkJ) from the original on 2023-04-13. Retrieved 2023-04-13.

1. **[^](#cite_ref-8)** ["FSTAT(8)"](https://www.tuhs.org/cgi-bin/utree.pl?file=4.3BSD-Tahoe/usr/man/cat8/fstat.0). *www.tuhs.org*. 4.3BSD-Tahoe.

1. **[^](#cite_ref-9)** ["v18i057: REVISED ofiles, doesn't need Sun source"](https://sources.vsta.org/comp.sources.unix/volume18/ofiles.new). comp.sources.unix.

1. ^ [***a***](#cite_ref-fstat_10-0) [***b***](#cite_ref-fstat_10-1) ["v18i107: Show all open files status"](https://sources.vsta.org/comp.sources.unix/volume18/fstat2). comp.sources.unix.

1. ^ [***a***](#cite_ref-gh1_11-0) [***b***](#cite_ref-gh1_11-1) ["lsof has moved to GitHub and has a new release · Issue #39572 · Homebrew/homebrew-core"](https://github.com/Homebrew/homebrew-core/issues/39572#issuecomment-490877044). *GitHub*. [Archived](https://web.archive.org/web/20230413052713/https://github.com/Homebrew/homebrew-core/issues/39572#issuecomment-490877044) from the original on 2023-04-13. Retrieved 2023-04-13.

1. **[^](#cite_ref-12)** ["lsof maintaining.md"](https://github.com/lsof-org/lsof/blob/master/docs/maintaining.md). *GitHub*. lsof-org. 10 April 2023. [Archived](https://web.archive.org/web/20230413052714/https://github.com/lsof-org/lsof/blob/master/docs/maintaining.md) from the original on 13 April 2023. Retrieved 13 April 2023.

1. **[^](#cite_ref-lsof(8)_13-0)** ["lsof"](https://man7.org/linux/man-pages/man8/lsof.8.html). Retrieved 16 July 2020.

## External links

- [Old site](http://people.freebsd.org/~abe/)

- [lsof-l mailing list](https://lists.purdue.edu/mailman/listinfo/lsof-l)

- [mirror of legacy sources](http://ftp.mirrorservice.org/sites/lsof.itap.purdue.edu/pub/tools/unix/lsof/)

- [lsof(8)](https://linux.die.net/man/8/lsof) – [Linux](/source/Linux) Administration and Privileged Commands [Manual](/source/Man_page)

- [lsof(8)](https://keith.github.io/xcode-man-pages/lsof.8.html) – [Darwin](/source/Darwin_(operating_system)) and [macOS](/source/MacOS) System Manager's [Manual](/source/Man_page)

- [Using lsof](http://danielmiessler.com/study/lsof)

- [Lsof FAQ](http://ftp.mirrorservice.org/sites/lsof.itap.purdue.edu/pub/tools/unix/lsof/FAQ)

- Sam Nelson's [PCP](https://web.archive.org/web/20070509052951/http://www.unix.ms/pcp/) script, an alternative to "lsof -i" for Solaris.

- [Glsof](https://glsof.sourceforge.net/) is two separate utilities (Queries and Filemonitor) based on lsof.

- [Sloth](https://github.com/sveinbjornt/Sloth) is a macOS graphical interface for lsof

- [Manpage of LSOF](https://netadmintools.com/html/lsof.man.html)

v t e Unix command-line utilities and shell builtins File system cat chattr chmod chown chgrp cksum cmp cp dd du df file fuser ln ls mkdir mv pax pwd rm rmdir split tee touch type umask Processes at bg crontab fg kill nice ps time User environment env exit logname mesg talk tput uname who write Text processing awk basename comm csplit cut diff dirname ed ex fold head iconv join m4 more nl paste patch printf read sed sort strings tail tr troff uniq vi wc xargs Shell builtins alias cd echo test unset wait Searching find grep Documentation man Software development ar ctags lex make nm strip yacc Miscellaneous bc cal dc expr lp od sleep true and false Categories Standard Unix programs Unix SUS2008 utilities List

---
Adapted from the Wikipedia article [Lsof](https://en.wikipedia.org/wiki/Lsof) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/Lsof?action=history)). Available under [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). Changes may have been made.
