• 要找福利?记不住网址?搜不到?如何与我们保持联系?试试 CTRL+D 把零点博客添加进您的浏览器收藏夹,一键直达永不失联!

系统管理-Linux who命令

linux系统 涛涛 56次浏览 0个评论

Linux who命令

Linux 命令大全 Linux 命令大全

Linux who命令用于显示系统中有哪些使用者正在上面,显示的资料包含了使用者 ID、使用的终端机、从哪边连上来的、上线时间、呆滞时间、CPU 使用量、动作等等。

使用权限:所有使用者都可使用。

语法

<span class="pln">who </span><span class="pun">-</span> <span class="pun">[</span><span class="pln">husfV</span><span class="pun">]</span> <span class="pun">[</span><span class="pln">user</span><span class="pun">]</span>

参数说明

  • -H 或 –heading:显示各栏位的标题信息列;
  • -i 或 -u 或 –idle:显示闲置时间,若该用户在前一分钟之内有进行任何动作,将标示成”.”号,如果该用户已超过24小时没有任何动作,则标示出”old”字符串;
  • -m:此参数的效果和指定”am i”字符串相同;
  • -q 或–count:只显示登入系统的帐号名称和总人数;
  • -s:此参数将忽略不予处理,仅负责解决who指令其他版本的兼容性问题;
  • -w 或-T或–mesg或–message或–writable:显示用户的信息状态栏;
  • –help:在线帮助;
  • –version:显示版本信息。

实例

显示当前登录系统的用户

<span class="com"># who  //显示当前登录系统的用户</span><span class="pln">
root   tty7     </span><span class="lit">2014</span><span class="pun">-</span><span class="lit">05</span><span class="pun">-</span><span class="lit">13</span> <span class="lit">12</span><span class="pun">:</span><span class="lit">12</span> <span class="pun">(:</span><span class="lit">0</span><span class="pun">)</span><span class="pln">
root   pts</span><span class="pun">/</span><span class="lit">0</span>    <span class="lit">2014</span><span class="pun">-</span><span class="lit">05</span><span class="pun">-</span><span class="lit">14</span> <span class="lit">17</span><span class="pun">:</span><span class="lit">09</span> <span class="pun">(:</span><span class="lit">0.0</span><span class="pun">)</span><span class="pln">
root   pts</span><span class="pun">/</span><span class="lit">1</span>    <span class="lit">2014</span><span class="pun">-</span><span class="lit">05</span><span class="pun">-</span><span class="lit">14</span> <span class="lit">18</span><span class="pun">:</span><span class="lit">51</span> <span class="pun">(</span><span class="lit">192.168</span><span class="pun">.</span><span class="lit">1.17</span><span class="pun">)</span><span class="pln">
root   pts</span><span class="pun">/</span><span class="lit">2</span>    <span class="lit">2014</span><span class="pun">-</span><span class="lit">05</span><span class="pun">-</span><span class="lit">14</span> <span class="lit">19</span><span class="pun">:</span><span class="lit">48</span> <span class="pun">(</span><span class="lit">192.168</span><span class="pun">.</span><span class="lit">1.17</span><span class="pun">)</span>

显示标题栏

<span class="com"># who -H</span><span class="pln">
NAME   LINE     TIME       COMMENT
root   tty7     </span><span class="lit">2014</span><span class="pun">-</span><span class="lit">05</span><span class="pun">-</span><span class="lit">13</span> <span class="lit">12</span><span class="pun">:</span><span class="lit">12</span> <span class="pun">(:</span><span class="lit">0</span><span class="pun">)</span><span class="pln">
root   pts</span><span class="pun">/</span><span class="lit">0</span>    <span class="lit">2014</span><span class="pun">-</span><span class="lit">05</span><span class="pun">-</span><span class="lit">14</span> <span class="lit">17</span><span class="pun">:</span><span class="lit">09</span> <span class="pun">(:</span><span class="lit">0.0</span><span class="pun">)</span><span class="pln">
root   pts</span><span class="pun">/</span><span class="lit">1</span>    <span class="lit">2014</span><span class="pun">-</span><span class="lit">05</span><span class="pun">-</span><span class="lit">14</span> <span class="lit">18</span><span class="pun">:</span><span class="lit">51</span> <span class="pun">(</span><span class="lit">192.168</span><span class="pun">.</span><span class="lit">1.17</span><span class="pun">)</span><span class="pln">
root   pts</span><span class="pun">/</span><span class="lit">2</span>    <span class="lit">2014</span><span class="pun">-</span><span class="lit">05</span><span class="pun">-</span><span class="lit">14</span> <span class="lit">19</span><span class="pun">:</span><span class="lit">48</span> <span class="pun">(</span><span class="lit">192.168</span><span class="pun">.</span><span class="lit">1.17</span><span class="pun">)</span>

显示用户登录来源

<span class="com"># who -l -H</span><span class="pln">
NAME   LINE     TIME       IDLE     PID COMMENT
LOGIN  tty4     </span><span class="lit">2014</span><span class="pun">-</span><span class="lit">05</span><span class="pun">-</span><span class="lit">13</span> <span class="lit">12</span><span class="pun">:</span><span class="lit">11</span>        <span class="lit">852</span><span class="pln"> id</span><span class="pun">=</span><span class="lit">4</span><span class="pln">
LOGIN  tty5     </span><span class="lit">2014</span><span class="pun">-</span><span class="lit">05</span><span class="pun">-</span><span class="lit">13</span> <span class="lit">12</span><span class="pun">:</span><span class="lit">11</span>        <span class="lit">855</span><span class="pln"> id</span><span class="pun">=</span><span class="lit">5</span><span class="pln">
LOGIN  tty2     </span><span class="lit">2014</span><span class="pun">-</span><span class="lit">05</span><span class="pun">-</span><span class="lit">13</span> <span class="lit">12</span><span class="pun">:</span><span class="lit">11</span>        <span class="lit">862</span><span class="pln"> id</span><span class="pun">=</span><span class="lit">2</span><span class="pln">
LOGIN  tty3     </span><span class="lit">2014</span><span class="pun">-</span><span class="lit">05</span><span class="pun">-</span><span class="lit">13</span> <span class="lit">12</span><span class="pun">:</span><span class="lit">11</span>        <span class="lit">864</span><span class="pln"> id</span><span class="pun">=</span><span class="lit">3</span><span class="pln">
LOGIN  tty6     </span><span class="lit">2014</span><span class="pun">-</span><span class="lit">05</span><span class="pun">-</span><span class="lit">13</span> <span class="lit">12</span><span class="pun">:</span><span class="lit">11</span>        <span class="lit">867</span><span class="pln"> id</span><span class="pun">=</span><span class="lit">6</span><span class="pln">
LOGIN  tty1     </span><span class="lit">2014</span><span class="pun">-</span><span class="lit">05</span><span class="pun">-</span><span class="lit">13</span> <span class="lit">12</span><span class="pun">:</span><span class="lit">11</span>       <span class="lit">1021</span><span class="pln"> id</span><span class="pun">=</span><span class="lit">1</span>

显示终端属性

<span class="com"># who -T -H</span><span class="pln">
NAME    LINE     TIME       COMMENT
root   </span><span class="pun">+</span><span class="pln"> tty7     </span><span class="lit">2014</span><span class="pun">-</span><span class="lit">05</span><span class="pun">-</span><span class="lit">13</span> <span class="lit">12</span><span class="pun">:</span><span class="lit">12</span> <span class="pun">(:</span><span class="lit">0</span><span class="pun">)</span><span class="pln">
root   </span><span class="pun">+</span><span class="pln"> pts</span><span class="pun">/</span><span class="lit">0</span>    <span class="lit">2014</span><span class="pun">-</span><span class="lit">05</span><span class="pun">-</span><span class="lit">14</span> <span class="lit">17</span><span class="pun">:</span><span class="lit">09</span> <span class="pun">(:</span><span class="lit">0.0</span><span class="pun">)</span><span class="pln">
root   </span><span class="pun">-</span><span class="pln"> pts</span><span class="pun">/</span><span class="lit">1</span>    <span class="lit">2014</span><span class="pun">-</span><span class="lit">05</span><span class="pun">-</span><span class="lit">14</span> <span class="lit">18</span><span class="pun">:</span><span class="lit">51</span> <span class="pun">(</span><span class="lit">192.168</span><span class="pun">.</span><span class="lit">1.17</span><span class="pun">)</span><span class="pln">
root   </span><span class="pun">-</span><span class="pln"> pts</span><span class="pun">/</span><span class="lit">2</span>    <span class="lit">2014</span><span class="pun">-</span><span class="lit">05</span><span class="pun">-</span><span class="lit">14</span> <span class="lit">19</span><span class="pun">:</span><span class="lit">48</span> <span class="pun">(</span><span class="lit">192.168</span><span class="pun">.</span><span class="lit">1.17</span><span class="pun">)</span>

只显示当前用户

<span class="com"># who -m -H</span><span class="pln">
NAME   LINE     TIME       COMMENT
root   pts</span><span class="pun">/</span><span class="lit">1</span>    <span class="lit">2014</span><span class="pun">-</span><span class="lit">05</span><span class="pun">-</span><span class="lit">14</span> <span class="lit">18</span><span class="pun">:</span><span class="lit">51</span> <span class="pun">(</span><span class="lit">192.168</span><span class="pun">.</span><span class="lit">1.17</span><span class="pun">)</span>

精简模式显示

<span class="com"># who -q</span><span class="pln">
root root root root
</span><span class="com"># users=4</span>

欢迎转载本文:系统管理-Linux who命令
喜欢 (0)
[ld]
分享 (0)
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址