# 使用 Homebrew, apk, apt, dnf, Nix, pacman, zypper 安装 lsof

查看 lsof 的安装路径、可执行文件、元数据以及面向 AI 代理工作流的安全说明。

## 安装

```sh
sudo av install brew:lsof
```

其他安装命令:

### macOS

- Homebrew (100%):

```sh
brew install lsof
```

  证据: local Homebrew formula metadata

### Linux

- apk (92%):

```sh
sudo apk add lsof
```

  证据: Alpine Linux edge package indexes: lsof from https://dl-cdn.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz

- Debian apt (92%):

```sh
sudo apt install lsof
```

  证据: Debian stable package indexes: lsof from https://deb.debian.org/debian/dists/stable/main/binary-amd64/Packages.xz

- dnf (92%):

```sh
sudo dnf install lsof
```

  证据: Fedora Rawhide package metadata: lsof from https://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/Everything/x86_64/os/repodata/07190dc5ae9f35ae73866675fed6d95fe6e8d9fe22c9d7cdf85862cb2ed24a4c-primary.xml.zst

- Nix (92%):

```sh
nix profile install nixpkgs#lsof
```

  证据: nixpkgs package indexes: pkgs/by-name/ls/lsof/package.nix from https://api.github.com/repos/NixOS/nixpkgs/git/trees/master?recursive=1

- pacman (92%):

```sh
sudo pacman -S lsof
```

  证据: Arch Linux sync databases: lsof from https://geo.mirror.pkgbuild.com/extra/os/x86_64/extra.db.tar.gz

- zypper (92%):

```sh
sudo zypper install lsof
```

  证据: openSUSE Tumbleweed package metadata: lsof from https://download.opensuse.org/tumbleweed/repo/oss/repodata/50b07339cb64c8ed4091bdbabddadc1ff5737b090e478818a195b40d8a3292861a879139b4a3987c31109699fde9fbf4a716367ddf4eef77da75f96e3193d6ed-primary.xml.zst

## 软件包事实

- **软件包键:** brew:lsof
- **软件包管理器:** Homebrew
- **版本:** 4.99.7
- **来源摘要:** Utility to list open files
- **主页:** <https://github.com/lsof-org/lsof>
- **仓库:** <https://github.com/lsof-org/lsof>
- **最后更新:** 2026-06-16T17:44:41Z
- **已生成:** 2026-08-03T19:37:03+00:00

## 可执行文件

- lsof (别名)

## 安装行为

- Bottle: 不可用

## 版本和新鲜度

- 页面生成时间: 2026-08-03
- 管理器版本: 4.99.7
## 项目历史与用法

lsof, short for LiSt Open Files, is a long-running Unix diagnostic command for showing which processes have files, directories, devices, sockets, and other file-like objects open. Its official documentation describes common uses such as finding processes blocking unmounts, locating unlinked open files, inspecting network sockets, and filtering by PID, command, or user.

### 项目历史

The official lsof documentation states that Vic Abell originally developed and maintained lsof beginning in 1994. The project later moved under the lsof-org team on GitHub, which now publishes the current releases and Read the Docs documentation.

lsof's importance comes from the Unix everything-is-a-file model. The official manpage describes support across many Unix dialects, including Linux, Darwin/macOS, FreeBSD, NetBSD, OpenBSD, Solaris, and OpenIndiana, and explains that open files include regular files, directories, character and block devices, executing text references, libraries, streams, internet sockets, NFS files, and Unix-domain sockets.

### 采用历史

lsof is one of the canonical system-administration packages. The official docs say it is provided by package managers, and the supplied package facts list availability through Homebrew, Alpine, Debian/Ubuntu, Fedora/DNF, Arch, Nix, and openSUSE/Zypper.

The GitHub repository was created for the maintained upstream in 2018 and continues to receive updates. The project documentation lists active support and CI coverage across major Unix-like systems, which helps downstream package maintainers keep it viable despite kernel and platform-specific internals.

### 使用方式

Administrators and developers use lsof to answer practical questions: which process has a file open, why a filesystem cannot be unmounted, where deleted-but-open files are consuming disk space, which TCP or UDP sockets a process owns, and what a named command or user has open.

The official manpage is unusually rich because lsof has to expose platform-specific kernel data in a portable CLI. It includes selectors for paths, PIDs, users, commands, network addresses, file descriptors, zones, repeat mode, parseable output via `-F`, and device-cache behavior.

### 为什么软件包爱好者会关心

For package nerds, lsof is foundational plumbing. It is a tiny command with outsized diagnostic value, but it is hard to maintain because it tracks kernel data structures and Unix dialect differences. That combination explains why it is routinely installed by default or close to default in sysadmin toolsets, containers, rescue environments, and debugging checklists.

### 时间线

- 1994: Vic Abell begins developing and maintaining lsof.
- 2018: lsof-org/lsof GitHub repository is created for current upstream maintenance.
- 2020s: lsof-org maintains Read the Docs documentation and GitHub releases.
- 2026: Official docs list active support for Linux, FreeBSD, Darwin/macOS, NetBSD, OpenBSD, Solaris/OpenIndiana, and CI testing across common distributions.

### Related projects

- Related diagnostics include fuser, ps, ss, netstat, procfs tools, and platform-specific filesystem or socket inspection commands. lsof remains distinctive because it unifies process, file descriptor, filesystem, and network views in one command.

### 来源

- <https://api.github.com/repos/lsof-org/lsof>
- <https://github.com/lsof-org/lsof>
- <https://lsof.readthedocs.io/en/latest/>
- <https://lsof.readthedocs.io/en/latest/manpage/>
- source_facts.package-manager


## 安全说明

narrow executable package without higher-risk signals.

- **Geiger 风险:** 绿色 / 低
- narrow executable package without higher-risk signals

## 其他软件包管理器记录

- Debian apt - liblsof-dev - 4.99.4+dfsg-2: normalized package name match | Debian stable package indexes: liblsof-dev from https://deb.debian.org/debian/dists/stable/main/binary-amd64/Packages.xz | utility to list open files (development files) | https://github.com/lsof-org/lsof
- Debian apt - liblsof0 - 4.99.4+dfsg-2: normalized package name match | Debian stable package indexes: liblsof0 from https://deb.debian.org/debian/dists/stable/main/binary-amd64/Packages.xz | utility to list open files (shared library) | https://github.com/lsof-org/lsof
- Debian apt - lsof - 4.99.4+dfsg-2: normalized package name match | Debian stable package indexes: lsof from https://deb.debian.org/debian/dists/stable/main/binary-amd64/Packages.xz | utility to list open files | https://github.com/lsof-org/lsof
- Nix - lsof: normalized package name match | nixpkgs package indexes: pkgs/by-name/ls/lsof/package.nix from https://api.github.com/repos/NixOS/nixpkgs/git/trees/master?recursive=1
- Ubuntu apt - lsof - 4.95.0-1build3: normalized package name match | Ubuntu 24.04 LTS package indexes: lsof from https://archive.ubuntu.com/ubuntu/dists/noble/main/binary-amd64/Packages.gz | utility to list open files | https://github.com/lsof-org/lsof
- apk - lsof - 4.99.7-r0: normalized package name match | Alpine Linux edge package indexes: lsof from https://dl-cdn.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz | LiSt Open Files | https://github.com/lsof-org/lsof
- apk - lsof-doc - 4.99.7-r0: normalized package name match | Alpine Linux edge package indexes: lsof-doc from https://dl-cdn.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz | LiSt Open Files (documentation) | https://github.com/lsof-org/lsof
- dnf - lsof - 4.99.6-2.fc45: normalized package name match | Fedora Rawhide package metadata: lsof from https://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/Everything/x86_64/os/repodata/07190dc5ae9f35ae73866675fed6d95fe6e8d9fe22c9d7cdf85862cb2ed24a4c-primary.xml.zst | A utility which lists open files on a Linux/UNIX system | https://github.com/lsof-org/lsof
- pacman - lsof - 4.99.7-1: normalized package name match | Arch Linux sync databases: lsof from https://geo.mirror.pkgbuild.com/extra/os/x86_64/extra.db.tar.gz | Lists open files for running Unix processes | https://github.com/lsof-org/lsof
- zypper - liblsof0 - 4.99.7-1.3: normalized package name match | openSUSE Tumbleweed package metadata: liblsof0 from https://download.opensuse.org/tumbleweed/repo/oss/repodata/50b07339cb64c8ed4091bdbabddadc1ff5737b090e478818a195b40d8a3292861a879139b4a3987c31109699fde9fbf4a716367ddf4eef77da75f96e3193d6ed-primary.xml.zst | Library for listing information about files opened by process | https://github.com/lsof-org/lsof
- zypper - lsof - 4.99.7-1.3: normalized package name match | openSUSE Tumbleweed package metadata: lsof from https://download.opensuse.org/tumbleweed/repo/oss/repodata/50b07339cb64c8ed4091bdbabddadc1ff5737b090e478818a195b40d8a3292861a879139b4a3987c31109699fde9fbf4a716367ddf4eef77da75f96e3193d6ed-primary.xml.zst | A Program That Lists Information about Files Opened by Processes | https://github.com/lsof-org/lsof
- zypper - lsof-devel - 4.99.7-1.3: normalized package name match | openSUSE Tumbleweed package metadata: lsof-devel from https://download.opensuse.org/tumbleweed/repo/oss/repodata/50b07339cb64c8ed4091bdbabddadc1ff5737b090e478818a195b40d8a3292861a879139b4a3987c31109699fde9fbf4a716367ddf4eef77da75f96e3193d6ed-primary.xml.zst | Library for listing information about files opened by process | https://github.com/lsof-org/lsof


## Combined YAML source

View the package source record on GitHub. [combined/lsof.yml](https://github.com/mxcl/pkgdb/blob/main/combined/lsof.yml)


## 来源

- pkg.so package database
- Geiger risk classifier
- curated package history
- pkgdb category and tag curation
- external package-manager database matches
- cross-ecosystem install command graph
