lsof命令使用详解
2011-11-20 21:52
567 查看
lsof命令只能以root的权限执行
用法如下:
1. 显示开启文件abc.txt的进程
lsof abc.txt
2. 显示22端口现在被什么程序占用
lsof -i 22
3. 显示abc进程现在正在打开的文件
lsof -c abc
4. 显示归属gid的进程情况
lsof -g gid
5. 显示指定目录下被进程开启的文件,不会遍历该目录下的所有子目录
lsof +d /usr/local/
6. 显示指定目录下被进程开启的文件,会遍历该目录下得所有子目录
lsof +D /usr/local/
7. 显示使用fd为4的进程
lsof -d 4
8. 不进行域名解析,缺省会进行,比较慢
lsof -n
9. 查看进程号为12的进程打开了哪些文件
lsof -p 12
10. 让lsof重复执行,缺省15s刷新
lsof +|-r [t]
-r, lsof会永远执行,直到被中断
+r, lsof会一直执行,直到没可显示的内容
Example:
查看目前ftp连接的情况:lsof -i tcp@test.com:ftp -r
11. 列出打开文件的大小,如果大小为0,则空
lsof -s
12. 以UID,列出打开的文件
lsof -u username
13. 显示符合条件的进程情况
语法:lsof -i[46] [protocol][@hostname|hostaddr][:service|port]
46 -- IPV4 or IPV6
protocol -- TCP or UDP
hostname -- Internet host name
hostaddr -- IP地址
service -- /etc/service中的service name(可多选)
port -- 端口号(可多选)
Example:
TCP:25 - TCP and port 25
@1.1.1.1 - IP 1.1.1.1
tcp@test.com - TCP protocol, ftp service
用法如下:
1. 显示开启文件abc.txt的进程
lsof abc.txt
2. 显示22端口现在被什么程序占用
lsof -i 22
3. 显示abc进程现在正在打开的文件
lsof -c abc
4. 显示归属gid的进程情况
lsof -g gid
5. 显示指定目录下被进程开启的文件,不会遍历该目录下的所有子目录
lsof +d /usr/local/
6. 显示指定目录下被进程开启的文件,会遍历该目录下得所有子目录
lsof +D /usr/local/
7. 显示使用fd为4的进程
lsof -d 4
8. 不进行域名解析,缺省会进行,比较慢
lsof -n
9. 查看进程号为12的进程打开了哪些文件
lsof -p 12
10. 让lsof重复执行,缺省15s刷新
lsof +|-r [t]
-r, lsof会永远执行,直到被中断
+r, lsof会一直执行,直到没可显示的内容
Example:
查看目前ftp连接的情况:lsof -i tcp@test.com:ftp -r
11. 列出打开文件的大小,如果大小为0,则空
lsof -s
12. 以UID,列出打开的文件
lsof -u username
13. 显示符合条件的进程情况
语法:lsof -i[46] [protocol][@hostname|hostaddr][:service|port]
46 -- IPV4 or IPV6
protocol -- TCP or UDP
hostname -- Internet host name
hostaddr -- IP地址
service -- /etc/service中的service name(可多选)
port -- 端口号(可多选)
Example:
TCP:25 - TCP and port 25
@1.1.1.1 - IP 1.1.1.1
tcp@test.com - TCP protocol, ftp service
相关文章推荐
- lsof命令使用详解
- Linux lsof命令详解+使用lsof恢复文件
- lsof命令使用详解
- Linux lsof命令详解和使用示例(总结的比较详细)
- Linux lsof命令详解和使用示例【转】
- linux中less命令使用详解(内容分页显示)
- Ffmpeg快速命令使用 Ffmpeg选项详解 Ffmepg格式详解 常见视频文件格式详解
- FTP 命令的使用详解
- 把linux文本保存下来的命令 Linux 下 col 命令 使用详解
- chmod命令使用详解
- FINDSTR 命令使用详解(2)
- windows批处理命令使用详解
- dos命令之 arp (网络诊断与配置)使用详解
- Linux RPM 命令参数使用详解 查看 rpm包依赖性
- Ubuntu下tar命令详解使用
- spool命令使用详解
- linux 系统使用/管理之-----Linux常用命令详解
- Linux rpm 命令参数使用详解[介绍和应用]
- tcpdump命令使用详解
- Linux RPM 命令参数使用详解