2019-04-21 11:50:48 +08:00

33 lines
2.0 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<h1 id="last">last</h1>
<p>列出目前与过去登入系统的用户相关信息</p>
<h2 id="补充说明">补充说明</h2>
<p><strong>last命令</strong> 用于显示用户最近登录信息。单独执行last命令它会读取<code>/var/log/wtmp</code>的文件,并把该给文件的内容记录的登入系统的用户名单全部显示出来。</p>
<h3 id="语法">语法</h3>
<pre><code class="language-bash">last(选项)(参数)</code></pre>
<h3 id="选项">选项</h3>
<pre><code class="language-bash">-a把从何处登入系统的主机名称或ip地址显示在最后一行
-d将IP地址转换成主机名称
-f &lt;记录文件&gt;:指定记录文件。
-n &lt;显示列数&gt;或-&lt;显示列数&gt;:设置列出名单的显示列数;
-R不显示登入系统的主机名称或IP地址
-x显示系统关机重新开机以及执行等级的改变等信息。</code></pre>
<h3 id="参数">参数</h3>
<ul>
<li>用户名:显示用户登录列表;</li>
<li>终端:显示从指定终端的登录列表。</li>
</ul>
<h3 id="实例">实例</h3>
<p>last命令用了显示用户登录情况以下是直接显示固定行数的记录</p>
<pre><code class="language-bash">last -10
root pts/0 221.6.45.34 Tue Dec 17 09:40 still logged in
root pts/0 221.6.45.34 Mon Dec 16 09:00 - 11:57 (02:56)
root pts/0 222.94.97.122 Sun Dec 15 20:39 - 23:28 (02:48)
root pts/0 222.95.209.80 Sat Dec 14 14:39 - 14:58 (00:18)
root pts/0 221.6.45.34 Thu Dec 12 16:55 - 17:37 (00:41)
root pts/0 49.65.139.195 Wed Dec 11 20:40 - 21:16 (00:35)
root pts/0 49.65.139.195 Wed Dec 11 19:46 - 20:03 (00:17)
root pts/0 221.6.45.34 Tue Dec 10 14:41 - 15:52 (01:10)
root pts/0 221.6.45.34 Mon Dec 9 17:24 - 17:30 (00:06)
root pts/0 221.6.45.34 Mon Dec 9 09:38 - 11:41 (02:02)</code></pre>
<!-- Linux命令行搜索引擎https://jaywcjlove.github.io/linux-command/ -->