mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-12-21 02:55:49 +08:00
语法高亮,滚动条美化,设置页面调整
This commit is contained in:
@@ -4,9 +4,9 @@
|
||||
<p><strong>lsof命令</strong> 用于查看你进程打开的文件,打开文件的进程,进程打开的端口(TCP、UDP)。找回/恢复删除的文件。是十分方便的系统监视工具,因为lsof命令需要访问核心内存和各种文件,所以需要root用户执行。</p>
|
||||
<p>在linux环境下,任何事物都以文件的形式存在,通过文件不仅仅可以访问常规数据,还可以访问网络连接和硬件。所以如传输控制协议 (TCP) 和用户数据报协议 (UDP) 套接字等,系统在后台都为该应用程序分配了一个文件描述符,无论这个文件的本质如何,该文件描述符为应用程序与基础操作系统之间的交互提供了通用接口。因为应用程序打开文件的描述符列表提供了大量关于这个应用程序本身的信息,因此通过lsof工具能够查看这个列表对系统监测以及排错将是很有帮助的。</p>
|
||||
<h3 id="语法">语法</h3>
|
||||
<pre><code>lsof(选项)</code></pre>
|
||||
<pre><code class="language-bash">lsof(选项)</code></pre>
|
||||
<h3 id="选项">选项</h3>
|
||||
<pre><code>-a:列出打开文件存在的进程;
|
||||
<pre><code class="language-bash">-a:列出打开文件存在的进程;
|
||||
-c<进程名>:列出指定进程所打开的文件;
|
||||
-g:列出GID号进程详情;
|
||||
-d<文件号>:列出占用该文件号的进程;
|
||||
@@ -19,7 +19,7 @@
|
||||
-h:显示帮助信息;
|
||||
-v:显示版本信息。</code></pre>
|
||||
<h3 id="实例">实例</h3>
|
||||
<pre><code>lsof
|
||||
<pre><code class="language-bash">lsof
|
||||
command PID USER FD type DEVICE SIZE NODE NAME
|
||||
init 1 root cwd DIR 8,2 4096 2 /
|
||||
init 1 root rtd DIR 8,2 4096 2 /
|
||||
@@ -110,7 +110,7 @@ events/1 7 root cwd DIR 8,2 4096 2 /</co
|
||||
<li>NAME:打开文件的确切名称</li>
|
||||
</ol>
|
||||
<p>列出指定进程号所打开的文件:</p>
|
||||
<pre><code>lsof -p $pid</code></pre>
|
||||
<pre><code class="language-bash">lsof -p $pid</code></pre>
|
||||
<p>获取端口对应的进程ID=>pid</p>
|
||||
<pre><code>lsof -i:9981 -P -t -sTCP:LISTEN</code></pre>
|
||||
<pre><code class="language-bash">lsof -i:9981 -P -t -sTCP:LISTEN</code></pre>
|
||||
<!-- Linux命令行搜索引擎:https://jaywcjlove.github.io/linux-command/ -->
|
||||
|
||||
Reference in New Issue
Block a user