#listen #port #cli

bin+lib ports

列出监听端口

4 个版本 (重大变更)

0.4.0 2024 年 8 月 21 日
0.3.0 2024 年 8 月 19 日
0.2.0 2024 年 8 月 11 日
0.1.0 2024 年 7 月 9 日

986命令行工具

Download history 65/week @ 2024-07-03 44/week @ 2024-07-10 95/week @ 2024-08-07 142/week @ 2024-08-14

每月 237 次下载

GPL-3.0 或更高版

63KB
1.5K SLoC

ports

license: GPL v3+ GitHub Tag crates.io

列出监听端口。

有时候很难跟踪哪个进程使用了哪个端口,或者在后台运行了什么。

$ ports
COMMAND      PID  USER     TYPE  NODE        HOST:PORT
rapportd     449  Quentin  IPv4  TCP           *:61165
rapportd     449  Quentin  IPv6  TCP           *:61165
Python     22396  Quentin  IPv6  TCP            *:8000
rustrover  30928  Quentin  IPv6  TCP   127.0.0.1:63342
Transmiss  94671  Quentin  IPv4  TCP           *:51413
Transmiss  94671  Quentin  IPv6  TCP           *:51413
具有不同级别的详细程度。

$ ports -vv
COMMAND      PID  USER     TYPE  NODE        HOST:PORT  %CPU  %MEM  COMMAND
rapportd     449  Quentin  IPv4  TCP           *:61165   0.0   0.1  /usr/libexec/rapportd
rapportd     449  Quentin  IPv6  TCP           *:61165   0.0   0.1  /usr/libexec/rapportd
Python     22396  Quentin  IPv6  TCP            *:8000   0.0   0.2  /usr/local/Cellar/[email protected]/3.12.3/Frameworks/Python.framework/Versions/3.12/Resources/Python.app/Contents/MacOS/Python -m http.server
rustrover  30928  Quentin  IPv6  TCP   127.0.0.1:63342   7.2  34.5  /Applications/RustRover.app/Contents/MacOS/rustrover
Transmiss  94671  Quentin  IPv4  TCP           *:51413   0.0   0.1  /Applications/Transmission.app/Contents/MacOS/Transmission
Transmiss  94671  Quentin  IPv6  TCP           *:51413   0.0   0.1  /Applications/Transmission.app/Contents/MacOS/Transmission
$ ports -vvv
COMMAND      PID  USER     TYPE  NODE        HOST:PORT  %CPU  %MEM    START       TIME  COMMAND
rapportd     449  Quentin  IPv4  TCP           *:61165   0.0   0.1  12Jul24    3:05.13  /usr/libexec/rapportd
rapportd     449  Quentin  IPv6  TCP           *:61165   0.0   0.1  12Jul24    3:05.13  /usr/libexec/rapportd
Python     22396  Quentin  IPv6  TCP            *:8000   0.0   0.1   5:47PM    0:00.18  /usr/local/Cellar/[email protected]/3.12.3/Frameworks/Python.framework/Versions/3.12/Resources/Python.app/Contents/MacOS/Python -m http.server
rustrover  30928  Quentin  IPv6  TCP   127.0.0.1:63342  18.3  32.2  Mon06PM  295:40.56  /Applications/RustRover.app/Contents/MacOS/rustrover
Transmiss  94671  Quentin  IPv4  TCP           *:51413   0.0   0.2   3Aug24   96:41.80  /Applications/Transmission.app/Contents/MacOS/Transmission
Transmiss  94671  Quentin  IPv6  TCP           *:51413   0.0   0.2   3Aug24   96:41.80  /Applications/Transmission.app/Contents/MacOS/Transmission

安装

直接安装

$ wget https://github.com/qrichert/ports/releases/download/X.X.X/ports-X.X.X-xxx
$ sudo install ./ports-* /usr/local/bin/ports
$ sudo ln -s /usr/local/bin/ports /usr/local/bin/cr

手动构建

全局安装

$ git clone https://github.com/qrichert/ports.git
$ cd ports
$ make build
$ sudo make install

通过 Cargo 安装

cargo install ports
cargo install --git https://github.com/qrichert/ports.git

无运行时依赖