博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
lsof 快速起步
阅读量:4047 次
发布时间:2019-05-25

本文共 1705 字,大约阅读时间需要 5 分钟。

lsof 快速起步

C.F.AN etony@tom.com

nov 16, 2005

Abstract:

通过大量的示例介绍使用lsof的方法.

文档出处:http://io.expert.com.br/~salvatti/tutoriais/seguranca/site/www.aei.ca/pmatilus/pub/lsof-quickstart.txt

查看哪些进程对某个文件进行了调用:

$ lsof /etc/passwd

/tmp目录被垃圾文件塞满了, 但是, 用ls 又看不到太大文件, 谁干的?

$ lsof /tmp

一个进程打开一个文件, 然后将其设为 unlinked 状态, 则此文件资源仍能被进程使用, 但是其访问路径已经被删除了. 因此, 使用ls不能将其列出. 只有当进程结束时, 才能释放文件占用的资源

查找unlinked 文件, 选项 +L, 作用: 列出打开文件的连接数

$lsof +L

指定连接数的上限 $lsof +L1

同时指定文件系统, 则需要使用 -a(AND) 选项

$ lsof -a +L1 /home

查看谁令mount的分区无法卸载

$ lsof <file_system_name>

查看网络服务

$ lsof -i

$ lsof -i@aaa.bbb.ccc

$ lsof -iTCP@aaa.bbb.ccc:ftp-data *指定协议*

$ lsof -i4 *指定IP版本*

$ lsof -i6

例如: netstat -p -t -n 的输出为:

Proto Recv-Q Send-Q Local Address Foreign Address State

tcp 0 0 218.56.203.246:52634 202.109.72.72:7000 ESTABLISHED

则可以: tony@tony:~$ lsof -iTCP@202.109.72.72:7000

COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME

xchat 4505 tony 12u IPv4 5775 TCP 218.56.203.246:52634->202.109.72.72:afs3-fileserver (ESTABLISHED)

使用命令的PID

$ lsof -p <PID>

使用命令名称

$ lsof -c <first_characters_of_command_name_that_interest_you>

$ lsof -c sendmail

查看谁在使用设备文件

$ lsof /dev/hda6

$ id -u tony

1000

$ lsof -u1000 or $ lsof -utony

$ lsof -u^tony * 则是取反的意思*

更多信息参阅 lsof 的联机手册losf(1).

http://io.expert.com.br/~salvatti/tutoriais/seguranca/site/www.aei.ca/pmatilus/pub/lsof-quickstart.txt;

lsof 快速起步

This document was generated using the translator Version 2002-2-1 (1.71)

Copyright © 1993, 1994, 1995, 1996, , Computer Based Learning Unit, University of Leeds.

Copyright © 1997, 1998, 1999, , Mathematics Department, Macquarie University, Sydney.

The command line arguments were:

latex2html lsof.tex -split 1 -local_icons

The translation was initiated by tony on 2005-12-18

 

转载地址:http://aqfci.baihongyu.com/

你可能感兴趣的文章
[LeetCode By Python]7 Reverse Integer
查看>>
[leetCode By Python] 14. Longest Common Prefix
查看>>
[LeetCode By Python]121. Best Time to Buy and Sell Stock
查看>>
[LeetCode By Python]122. Best Time to Buy and Sell Stock II
查看>>
[LeetCode By Python]125. Valid Palindrome
查看>>
[LeetCode By Python]136. Single Number
查看>>
Android/Linux 内存监视
查看>>
Android2.1消息应用(Messaging)源码学习笔记
查看>>
android raw读取超过1M文件的方法
查看>>
MPMoviePlayerViewController和MPMoviePlayerController的使用
查看>>
CocoaPods实践之制作篇
查看>>
[Mac]Mac 操作系统 常见技巧
查看>>
苹果Swift编程语言入门教程【中文版】
查看>>
捕鱼忍者(ninja fishing)之游戏指南+游戏攻略+游戏体验
查看>>
iphone开发基础之objective-c学习
查看>>
iphone开发之SDK研究(待续)
查看>>
计算机网络复习要点
查看>>
Variable property attributes or Modifiers in iOS
查看>>
NSNotificationCenter 用法总结
查看>>
C primer plus 基础总结(一)
查看>>