lsof的应用
来源:互联网 发布:网络利大于弊的资料 编辑:程序博客网 时间:2024/04/29 12:56
sof命令的原始功能是列出打开的文件的进程,但LINUX下,所有的设备都是以文件的行式存在的,所以,lsof的功能很强大。
一般root用户才能 执行lsof命令,普通用户可以看见/usr/sbin/lsof命令,但是普通用户执行会显示“permission denied”
sof指令的用法如下:
lsof abc.txt 显示开启文件abc.txt的进程
lsof -i :22 知道22端口现在运行什么程序
lsof -c abc 显示abc进程现在打开的文件
lsof -g gid 显示归属gid的进程情况
lsof +d /usr/local/ 显示目录下被进程开启的文件
lsof +D /usr/local/ 同上,但是会搜索目录下的目录,时间较长
lsof -d 4 显示使用fd为4的进程
lsof -i 用以显示符合条件的进程情况
语法: lsof -i[46] [protocol][@hostname|hostaddr][:service|port]
46 --> IPv4 or IPv6
protocol --> TCP or UDP
hostname --> Internet host name
hostaddr --> IPv4位置
service --> /etc/service中的 service name (可以不只一个)
port --> 端口号 (可以不只一个)
例子: TCP:25 - TCP and port 25
@1.2.3.4 - Internet IPv4 host address 1.2.3.4
tcp@ohaha.ks.edu.tw:ftp - TCP protocol hosthaha.ks.edu.tw service name:ftp
lsof -n 不将IP转换为hostname,缺省是不加上-n参数
例子: lsof -i tcp@ohaha.ks.edu.tw:ftp -n
lsof -p 12 看进程号为12的进程打开了哪些文件
lsof +|-r [t] 控制lsof不断重复执行,缺省是15s刷新
-r,lsof会永远不断的执行,直到收到中断信号
+r,lsof会一直执行,直到没有档案被显示
例子:不断查看目前ftp连接的情况:lsof -i tcp@ohaha.ks.edu.tw:ftp -r
lsof -s 列出打开文件的大小,如果没有大小,则留下空白
lsof -u username 以UID,列出打开的文件
一般root用户才能 执行lsof命令,普通用户可以看见/usr/sbin/lsof命令,但是普通用户执行会显示“permission denied”
sof指令的用法如下:
lsof abc.txt 显示开启文件abc.txt的进程
lsof -i :22 知道22端口现在运行什么程序
lsof -c abc 显示abc进程现在打开的文件
lsof -g gid 显示归属gid的进程情况
lsof +d /usr/local/ 显示目录下被进程开启的文件
lsof +D /usr/local/ 同上,但是会搜索目录下的目录,时间较长
lsof -d 4 显示使用fd为4的进程
lsof -i 用以显示符合条件的进程情况
语法: lsof -i[46] [protocol][@hostname|hostaddr][:service|port]
46 --> IPv4 or IPv6
protocol --> TCP or UDP
hostname --> Internet host name
hostaddr --> IPv4位置
service --> /etc/service中的 service name (可以不只一个)
port --> 端口号 (可以不只一个)
例子: TCP:25 - TCP and port 25
@1.2.3.4 - Internet IPv4 host address 1.2.3.4
tcp@ohaha.ks.edu.tw:ftp - TCP protocol hosthaha.ks.edu.tw service name:ftp
lsof -n 不将IP转换为hostname,缺省是不加上-n参数
例子: lsof -i tcp@ohaha.ks.edu.tw:ftp -n
lsof -p 12 看进程号为12的进程打开了哪些文件
lsof +|-r [t] 控制lsof不断重复执行,缺省是15s刷新
-r,lsof会永远不断的执行,直到收到中断信号
+r,lsof会一直执行,直到没有档案被显示
例子:不断查看目前ftp连接的情况:lsof -i tcp@ohaha.ks.edu.tw:ftp -r
lsof -s 列出打开文件的大小,如果没有大小,则留下空白
lsof -u username 以UID,列出打开的文件
- lsof的应用
- 20130607Linux笔记--lsof应用
- lsof的用法
- lsof的使用
- Linux lsof 的使用
- lsof的使用
- lsof的用法
- lsof命令的用法
- lsof 的参数详解
- linux的lsof命令
- lsof的基本用法
- Linux-lsof的用法
- lsof的注意事项
- lsof的用途
- lsof的用法
- lsof命令的用法
- linux下的lsof的使用及其在取证分析时的应用
- lsof
- Patterns: Service Oriented Architecture And Web Services
- Programming Python, Second Edition
- JBoss at Work : A Practical Guide
- 2008届最佳开源CMS大赛决赛名单
- 软件工程师
- lsof的应用
- Retrieving the COM class factory for component with CLSID {00024500-0000-000
- Yafray - 浩南兄说
- c++实现同或运算
- 开发者角度看Google Chrome
- Linux之间NFS方式共享文件
- 主题:关于计算机编程的21条“规律”
- 页面加灰的方法
- 在linux系统强制登录用户推出系统