⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 linux 用户(user)查询篇 linuxsir_org.htm

📁 linuxSir 网站的精华文章
💻 HTM
📖 第 1 页 / 共 2 页
字号:
      <DIV class=codeblock><CODE>[beinan@localhost ~]$ finger -s 
      </CODE></DIV><BR><B>注解:</B>不加任何参数,也没有指定查询哪个用户,finger 会以默认以短格-s 
      来输出登录本机的所有用户的用户名(也被称为登录名Login)、真实名字(NAME)、在哪个终端登录(Tty)、写状态、空闲时间(Idle)、登录时间(Login 
      Time)、办公地点、办公电话等;
      <P></P>
      <P>在这个例子中,有beinan用户登录,真实名字是beinan sun 
      (这个名字是用户的真实名字,如果在添加用户时没有设置,是不会显示的),在tty1终端登录,空闭时间是1分39秒,登录时间是Nov /2/08:27 
      ,没有办公室名称,没有办公电话;</P>
      <P>请对照本例中beinan用户记录的解说,我们来看看本例中的 linuxsir用户信息;应该不难。</P>
      <P>关于写状态,如果在Tty 后面 
      没有任何输出,表示正在写入,如果有*出现,表示没有写入或被禁止,比如下面的例子,ftp用户没有通过终端登录系统,因为Tty是*,同时Tty后面还有一个* 
      ,表示禁止写入或没有写入状态(当用户没有登录时);<BR>
      <DIV class=codeblock><CODE>[beinan@localhost ~]$ finger -s ftp<BR>Login 
      Name Tty Idle Login Time Office Office Phone<BR>ftp FTP User * * No 
      logins</CODE></DIV>
      <P></P>
      <P>我们可以以短格式的来查询某个用户信息以短格式输出,比如下面的例子;<BR>
      <DIV class=codeblock><CODE>[beinan@localhost ~]$ finger -s 
      beinan</CODE></DIV>
      <P></P>
      <P><B>实例二:</B>关于长格式的用户信息的输出 -l 参数的实例;</P>
      <P>finger -l 
      如果不加用户名的情况下,可以列出所有通过tty登录的用户信息;如果您想查询某个用户,就直接指定用户,可以指定一个或多个;什么是tty登录?如果您在全屏文本界面操作的话,您可以通过按CTRL+F2或CTRL+F3 
      或CTRL+F4等, 以几个不同的用户登录到主机上,您就会看到,每个用户都有不同的tty;</P>
      <P>
      <DIV class=codeblock><CODE>[beinan@localhost ~]$ finger 
      -l<BR>[beinan@localhost ~]$ finger -l beinan linuxsir 
      注:可以同时查询几个用户信息,以长格式输出;</CODE></DIV>
      <P></P>
      <P>
      <DIV class=codeblock><CODE>[beinan@localhost ~]$ finger beinan<BR>Login: 
      beinan Name: beinan sun<BR>Directory: /home/beinan Shell: /bin/bash<BR>On 
      since Wed Nov 2 08:27 (CST) on tty1 2 hours 29 minutes idle<BR>On since 
      Wed Nov 2 10:50 (CST) on pts/0 from :0.0<BR>No mail.<BR>No 
      Plan.</CODE></DIV>
      <P></P>
      <P>在本例中,所查询的用户是beinan,真实名字是beinan sun ,家目录位于 /home/beinan ,所用SHELL类型是bash 
      ;然后就是通过哪个终端登录的,登录时间,是不是有mail ,有Plan 等;</P>
      <P><B>实例三:</B>参数组合的例子;</P>
      <P>
      <DIV class=codeblock><CODE>[beinan@localhost ~]$ finger -lp 
      beinan<BR>Login: beinan Name: beinan sun<BR>Directory: /home/beinan Shell: 
      /bin/bash<BR>On since Wed Nov 2 08:27 (CST) on tty1 2 hours 36 minutes 
      idle<BR>On since Wed Nov 2 10:50 (CST) on pts/0 from :0.0<BR>No 
      mail.</CODE></DIV>
      <P></P>
      <P><B>注解:</B>查询beinan用户信息,以长格式输出,并且不输出.Plan和.Project的内容;</P>
      <P><B>实例四:</B> finger -s 和w 及who的比较;</P>
      <P>对于finger 就说这么多吧,极为简单的工具,当用到-s 参数时,您最好和w和who工具对照,看看finger -s 和w 
      及who的输出有什么异同,w和who是查询哪些用户登录主机的;而finger -s 
      呢,无论是登录还是不登录的用户都可以查;但所查到的内容侧重有所不同;自己看看例子;</P>
      <P>
      <DIV class=codeblock><CODE>[beinan@localhost ~]$ finger -s<BR>Login Name 
      Tty Idle Login Time Office Office Phone<BR>beinan beinan sun tty1 3:03 Nov 
      2 08:27<BR>beinan beinan sun pts/0 Nov 2 10:50 (:0.0)<BR>linuxsir linuxsir 
      open tty2 1:26 Nov 2 10:03 linuxsir o +1-389-866-771<BR>[beinan@localhost 
      ~]$ w<BR>&nbsp;11:30:36 up 3:04, 3 users, load average: 0.30, 0.15, 
      0.10<BR>USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT<BR>beinan tty1 - 08:27 
      3:03m 2:52 0.00s /bin/sh /usr/X11R6/bin/startx<BR>linuxsir tty2 - 10:03 
      1:26m 0.01s 0.01s -bash<BR>beinan pts/0 :0.0 10:50 0.00s 0.16s 0.00s 
      w<BR>[beinan@localhost ~]$ who<BR>beinan tty1 Nov 2 08:27<BR>linuxsir tty2 
      Nov 2 10:03<BR>beinan pts/0 Nov 2 10:50 (:0.0)</CODE></DIV>
      <P></P>
      <P><FONT id=2.3 size=3><B><BR>3、查询登录主机的用户工具:w 、who 
      、users<BR></B></FONT></P>
      <P>w、who和users工具,是查询已登录当前主机的用户;另外finger -s 
      也同样能查询;侧重点不一样;请自己对比着看;毕竟简单,这里只是介绍 ;</P>
      <P>
      <DIV class=codeblock><CODE>[beinan@localhost ~]$ w<BR>&nbsp;12:09:56 up 
      3:43, 7 users, load average: 0.16, 0.10, 0.04<BR>USER TTY FROM LOGIN@ IDLE 
      JCPU PCPU WHAT<BR>beinan tty1 - 08:27 3:42m 3:09 0.00s /bin/sh 
      /usr/X11R6/bin/startx<BR>linuxsir tty2 - 10:03 2:06m 0.01s 0.01s 
      -bash<BR>beinan pts/0 :0.0 11:36 1:09 0.15s 0.15s bash<BR>beinan pts/1 
      :0.0 11:37 1:12 0.21s 0.21s bash<BR>beinan pts/2 :0.0 12:02 6:52 0.09s 
      0.09s bash<BR>beinan pts/3 :0.0 12:05 12.00s 0.11s 0.06s ssh 
      xmbnnbdl@linuxsir.org -p 17007<BR>beinan pts/4 :0.0 12:06 0.00s 0.21s 
      0.00s w<BR>[beinan@localhost ~]$ who<BR>beinan tty1 Nov 2 
      08:27<BR>linuxsir tty2 Nov 2 10:03<BR>beinan pts/0 Nov 2 11:36 
      (:0.0)<BR>beinan pts/1 Nov 2 11:37 (:0.0)<BR>beinan pts/2 Nov 2 12:02 
      (:0.0)<BR>beinan pts/3 Nov 2 12:05 (:0.0)<BR>beinan pts/4 Nov 2 12:06 
      (:0.0)<BR>[beinan@localhost ~]$ users<BR>beinan beinan beinan beinan 
      beinan beinan linuxsir</CODE></DIV>
      <P></P>
      <P><FONT id=2.4 size=3><B><BR>4、groups 
      用户所归属的用户组查询;<BR></B></FONT><BR>groups 用法很简单,就是查询用户所归属哪个或哪些用户组;</P>
      <P>
      <DIV class=codeblock><CODE>语法格式: groups 用户名</CODE></DIV>
      <P></P>
      <P>实例:</P>
      <P>
      <DIV class=codeblock><CODE>[beinan@localhost ~]$ groups beinan 
      注:查询beinan所归属的用户组; <BR>beinan : beinan 注:beinan 
      是beinan用户组下的成员;<BR>[beinan@localhost ~]$ groups linuxsir 
      注:查询linuxsir用户所归属的用户组;<BR>linuxsir : linuxsir root beinan 
      注:linuxsir用户是linuxsir用户组、beinan用户组、root用户组成员;</CODE></DIV>
      <P></P>
      <P>groups 主要是查询用户所归属的用户组名,最好和id命令相对比;这样对这两个工具都有所了解;</P>
      <P><FONT id=3 
      size=4><B><BR>三、后记;<BR></B></FONT><BR>本文是很简单的文档,花十分钟就能看得完,但对我来说既然想写入门级系列文档了,再简单也得告诉初学者,不是吗?写本文的时候,我已经把查询用户的工具列为《Linux 
      用户及用户组管理工具介绍》的文档中,但写着写着发现文档太长了,所以只好把用户的查询做为独立的一篇先发出来;</P>
      <P>我的下一篇文档计划是接着写用户管理的相关工具,比如用户的添加、删除、修改等工具;如果顺利的话,会在这两天完成,不过这仅仅是计划;因为在写超级权限控制的时候,我也说过用一到两天,而我却写十二天;<BR><FONT 
      id=4 
      size=4><B><BR>四、参与修正本文;<BR></B></FONT><BR>在以后本文档中,我想让大家来参与修正,毕竟一个人写的东西肯定会存在问题,几个脑袋总比一个脑袋要好的多吧;请大家多多指点;比如本文中关于用户查询工具工作原理可能表达不太准确或不足;另外w、who查询在线用户的原理没有提到,如果哪位弟兄有时间可以把查询在线用户的工具独列出来写成文档;谢谢;</P>
      <P><FONT id=5 size=4><B><BR>五、致谢;<BR></B></FONT></P>
      <P><FONT id=6 size=4><B><BR>六、相关文档;<BR></B></FONT><BR><A 
      href="http://www.linuxsir.org/main/?q=node/91">《Linux 
      用户(user)和用户组(group)管理概述》</A><BR><A 
      href="http://www.linuxsir.org/main/?q=node/98">《用户(user)和用户组(group)配置文件详解》</A><BR><A 
      href="http://www.linuxsir.org/main/?q=node/105">《Linux 
      用户(User)查询篇》</A><BR><A 
      href="http://www.linuxsir.org/main/?q=node/106">《Linux 用户管理工具介绍》</A><BR><A 
      href="http://www.linuxsir.org/main/?q=node/104">《Linux 
      系统中的超级权限的控制》</A><BR><A 
      href="http://www.linuxsir.org/main/?q=node/109">《在Linux系统中,批量添加用户的操作流程》</A></P></DIV>
      <DIV class=links>By 北南南北 at 2005/11/03 - 09:34 | <A 
      href="http://www.linuxsir.org/main/?q=taxonomy/term/1">Linux</A> | <A 
      href="http://www.linuxsir.org/main/?q=taxonomy/term/25">基础知识</A> | <A 
      title=共享你有关本文的思想和意见。 
      href="http://www.linuxsir.org/main/?q=comment/reply/105#comment">参与评论</A> 
      | 2720 阅读</DIV></DIV><A id=comment></A>
      <FORM action=?q=comment method=post>
      <DIV><INPUT type=hidden value=105 name=edit[nid]> </DIV></FORM><!-- end content -->
      <DIV id=footer>
      <CENTER><A href="http://www.linuxsir.org/"><IMG 
      src="Linux 用户(User)查询篇  LinuxSir_Org.files/logo.jpg"></A> <BR><A 
      href="http://www.miibeian.gov.cn/"><FONT color=blue 
      size=3><B>闽ICP备06025536号</B></FONT></A><BR>
      <SCRIPT language=JavaScript 
      src="Linux 用户(User)查询篇  LinuxSir_Org.files/cyberpolice.htm"></SCRIPT>
      <BR><A href="http://www.linuxsir.org/main/?q=node/78"><FONT color=blue 
      size=3><B>© 2002-2006 LinuxSir.Org</B></FONT></A><BR></CENTER></DIV></TD>
    <TD id=sidebar-right>
      <DIV class="block block-block" id=block-block-2>
      <H2 class=title>基础知识</H2>
      <DIV class=content>
      <UL>
        <LI><A href="http://www.linuxsir.org/main/?q=taxonomy/term/23">安装配置</A> 
        <LI><A 
        href="http://www.linuxsir.org/main/?q=taxonomy/term/1/25/">基础入门</A> 
        <LI><A href="http://www.linuxsir.org/main/?q=taxonomy/term/22/">硬件解决</A> 

        <LI><A href="http://www.linuxsir.org/main/?q=taxonomy/term/21">软件管理</A> 
        <LI><A 
        href="http://www.linuxsir.org/main/?q=taxonomy/term/35/48/">重要资源</A> 
        </LI></UL></DIV></DIV>
      <DIV class="block block-block" id=block-block-4>
      <H2 class=title>软件应用</H2>
      <DIV class=content>
      <UL>
        <LI><A href="http://www.linuxsir.org/main/?q=taxonomy/term/30">网络工具</A> 
        <LI><A href="http://www.linuxsir.org/main/?q=taxonomy/term/32">图形图像</A> 
        <LI><A href="http://www.linuxsir.org/main/?q=taxonomy/term/31">音乐视频</A> 
        <LI><A href="http://www.linuxsir.org/main/?q=taxonomy/term/49">字体中文</A> 
        <LI><A href="http://www.linuxsir.org/main/?q=taxonomy/term/33">软件其它</A> 
        </LI></UL></DIV></DIV>
      <DIV class="block block-block" id=block-block-5>
      <H2 class=title>网络服务器</H2>
      <DIV class=content>
      <UL>
        <LI><A href="http://www.linuxsir.org/main/?q=taxonomy/term/27">文件服务器<A> 
        <LI><A 
        href="http://www.linuxsir.org/main/?q=taxonomy/term/28">Web服务器</A> 
        <LI><A href="http://www.linuxsir.org/main/?q=taxonomy/term/29">邮件服务器</A> 

        <LI><A href="http://www.linuxsir.org/main/?q=taxonomy/term/37">数据库应用</A> 

        <LI><A href="http://www.linuxsir.org/main/?q=taxonomy/term/50">服务器其它</A> 
        </LI></UL></DIV></DIV>
      <DIV class="block block-comment" id=block-comment-0>
      <H2 class=title>最新评论</H2>
      <DIV class=content>
      <DIV class=item-list>
      <UL>
        <LI><A 
        href="http://www.linuxsir.org/main/?q=node/222#comment-624">错了</A><BR>8 
        min 8 sec 前
        <LI><A 
        href="http://www.linuxsir.org/main/?q=node/222#comment-623">q</A><BR>27 
        min 45 sec 前
        <LI><A 
        href="http://www.linuxsir.org/main/?q=node/222#comment-622">有些道理</A><BR>49 
        min 14 sec 前
        <LI><A 
        href="http://www.linuxsir.org/main/?q=node/219#comment-621">"内置的摄像头也能用这个吗?"</A><BR>13 
        hours 54 min 前
        <LI><A 
        href="http://www.linuxsir.org/main/?q=node/80#comment-620">终于知道了...</A><BR>23 
        hours 9 min 前
        <LI><A 
        href="http://www.linuxsir.org/main/?q=node/106#comment-619">okok</A><BR>2 
        days 14 hours 前
        <LI><A 
        href="http://www.linuxsir.org/main/?q=node/93#comment-618">那要除去阴影呢?</A><BR>3 
        days 19 hours 前
        <LI><A 
        href="http://www.linuxsir.org/main/?q=node/227#comment-617">不错的机会</A><BR>4 
        days 6 hours 前
        <LI><A 
        href="http://www.linuxsir.org/main/?q=node/221#comment-616">配置可执行程序的路径</A><BR>4 
        days 12 hours 前
        <LI><A 
        href="http://www.linuxsir.org/main/?q=node/222#comment-615">修改hostname出现的问题</A><BR>5 
        days 2 hours 
前</LI></UL></DIV></DIV></DIV></TD></TR></TBODY></TABLE></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -