admin 管理员组

文章数量: 893893

who?

who?用过unix的都知道吧,man一下就出来这些: 

NAME
     who -- display who is on the system

SYNOPSIS
     who [-HmqsTu] [am I] [file]

DESCRIPTION
     The who utility displays information about currently logged in users.  By
     default, this includes the login name, tty name, date and time of login
     and remote hostname if not local.

     The options are as follows:

     -H      Write column headings above the output.

     -m      Show information about the terminal attached to standard input
             only.

     -q      ``Quick mode'': List the names and number of logged in users in
             columns.  All other command line options are ignored.

     -s      Show the name, line and time fields only.  This is the default.

     -T      Indicate whether each user is accepting messages.  One of the
             following characters is written:

             +  User is accepting messages.
             -  User is not accepting messages.
             ?  An error occurred.

     -u      Show idle time for each user in hours and minutes as hh:mm, `.'
             if the user has been idle less that a minute, and ``old'' if the
             user has been idle more than 24 hours.

     am I    Equivalent to -m.

     By default, who gathers information from the file /var/run/utmp.  An
     alternate file may be specified which is usually /var/log/wtmp (or
     /var/log/wtmp.[0-6] depending on site policy as wtmp can grow quite large
     and daily versions may or may not be kept around after compression by
     ac(8)).  The wtmp file contains a record of every login, logout, crash,
     shutdown and date change since wtmp was last truncated or created.
     If /var/log/wtmp is being used as the file, the user name may be empty or
     one of the special characters '|', '}' and '~'.  Logouts produce an out-
     put line without any user name.  For more information on the special
     characters, see utmp(5).

ENVIRONMENT
     The COLUMNS, LANG, LC_ALL and LC_TIME environment variables affect the
     execution of who as described in environ(7).

FILES
     /var/run/utmp
     /var/log/wtmp
     /var/log/wtmp.[0-6]

DIAGNOSTICS
     The who utility exits 0 on success, and >0 if an error occurs.

可能没人觉得它有什么用处,不过就看看谁也在上面吗?
但我却经常用它,用它来看一个人还在吗?
研究了一下man,发觉who -u必较适合我,能看看别人是不是在发呆。。。
who -u | grep prentice 就能看到prentice的登陆基本信息,还有他发呆了多久。

prentice         ttyp6    Apr 14 15:46 23:08 (192.168.11.202)
prentice         ttyp7    Apr 14 16:07 05:00 (192.168.11.202)
prentice         ttypa    Apr 14 20:31   .   (192.168.11.202)
prentice         ttypj    Apr 14 17:30 03:20 (192.168.11.202)


who读取的是系统登陆记录文件,我所在的freebsd上是/var/log/wtmp。用who [file]就能把file中的登陆信息全部读取出来。至于其他的参数就没什么用了。

but,who i am,did i have permission to who you?

本文标签: who