lsof examples
lsof examples
January 10, 2025
通用
- ^ 表示非
- 多个值是
CSV
形式
lsof -i(internet)
-i 后可以有空格 [46][protocol][@hostname|hostaddr][:service|port]
46
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.protocol
is a protocol name - TCP, UDPhostname
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.hostaddr
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.service
is an /etc/services name - e.g., smtp -or a list of them.port
is a port number, or a list of them.
lsof -i
@10.10.129.99:8080
lsof -i
4tcp
all ipv4 tcp
lsof -i
4udp
all ipv4 udp
lsof -i
4udp@localhost
all localhost ipv4 udp
lsof -i
4tcp@10.10.129.99
all 10.10.129.99 tcp
lsof -i
:ssh
service ssh
lsof -i
:22
port 22
lsof -i
TCP -sTCP:LISTEN
tcp state Listen
lsof -p
pid
by pid
lsof /test.sock
lsof -t
/test.sock
-t(terse) 简要的 get pid
lsof -c
^
java
找到以非 java 命令(command)开始的
lsof -c
java
找到以 java 命令(command)开始的
lsof +d
/dir
该 /dir目录(directory) 下所有
lsof -d
1
查看 descriptor = 1(标准输出)
lsof -d
1,2
查看 descriptor = 1,2(标准输出、标准错误)
lsof -a
-c
java -d
3-10
条件组合查询 -a(and) -c(command) -d(范围)
lsof -u
root
该 root 下所有 -u(user)
lsof -U
-U(Unix domain socket)
Last updated on