Linux -- who whoami

來源:互聯網
上載者:User

標籤:des   cWeb   style   blog   os   java   io   strong   ar   

(一)

whoami  是一個相當簡單的命令


(二)
 `who‘: Print who is currently logged in
============================================

`who‘ prints information about users who are currently logged on.
Synopsis:

     `who‘ [OPTION] [FILE] [am i]

   If given no non-option arguments, `who‘ prints the following
information for each user currently logged on: login name, terminal
line, login time, and remote hostname or X display.

   If given one non-option argument, `who‘ uses that instead of a
default system-maintained file (often `/var/run/utmp‘ or `/etc/utmp‘)
as the name of the file containing the record of users logged on.
`/var/log/wtmp‘ is commonly given as an argument to `who‘ to look at
who has previously logged on.

   If given two non-option arguments, `who‘ prints only the entry for
the user running it (determined from its standard input), preceded by
the hostname.  Traditionally, the two arguments given are `am i‘, as in
`who am i‘.

   Time stamps are listed according to the time zone rules specified by
the `TZ‘ environment variable, or by the system default rules if `TZ‘
is not set.  *Note Specifying the Time Zone with `TZ‘: (libc)TZ
Variable.

#記住使用者的概念非常廣泛,不僅僅指實際存在的使用者,還包括各種特殊使用者,一般id為 0 ~ 500

#參考/etc/passwd檔案更深入理解使用者的概念。
   The program accepts the following options.  Also see *note Common
options::.

 

I.
****************************************************************************************
`-a‘
`--all‘
     Same as `-b -d --login -p -r -t -T -u‘.

 

*************************************************************************************


`-b‘
`--boot‘
     Print the date and time of last system boot.    #最後一次系統啟動的時間

#who -a 所顯示的第一行

**************************************************************************************

`-r‘
`--runlevel‘
     Print the current (and maybe previous) run-level of the init
     process.

#who -a 所顯示的第二行,運行層級

****************************************************************************************

`-l‘
`--login‘
     List only the entries that correspond to processes via which the
     system is waiting for a user to login.  The user name is always
     `LOGIN‘.

#who -a 本文的前六行,等待登入的使用者連接埠

************************************************************************************************

`-u‘
     After the login time, print the number of hours and minutes that
     the user has been idle.  `.‘ means the user was active in the last
     minute.  `old‘ means the user has been idle for more than 24 hours.

#本文who -a 中的已登入的使用者,給出 “登入地址” “登入時間” 還有其他一些資料

*************************************************************************************


`-w‘
`-T‘
`--mesg‘
`--message‘
`--writable‘
     After each login name print a character indicating the user‘s
     message status:

          `+‘ allowing `write‘ messages
          `-‘ disallowing `write‘ messages
          `?‘ cannot find terminal device

#顯示是否可以用write命令去發送資訊

***************************************************************************************

`-H‘
`--heading‘
     Print a line of column headings.

#這是個比較好的輔助命令,能提高顯示結果的可讀性

************************************************************************************

II

其他一些參數

1、顯示dead processes 和 active processes
`-d‘
`--dead‘
     Print information corresponding to dead processes.

`-p‘
`--process‘
     List active processes spawned by init.
`-p‘
`--process‘
     List active processes spawned by init.

2、比whoami 稍微詳細的結果

`-m‘
     Same as `who am i‘.



3、顯示登入的使用者總數

`-q‘
`--count‘
     Print only the login names and the number of users logged on.
     Overrides all other options.

 

4、其他
`--lookup‘
     Attempt to canonicalize hostnames found in utmp through a DNS
     lookup.  This is not the default because it can cause significant
     delays on systems with automatic dial-up internet access.

`-s‘
     Ignored; for compatibility with other versions of `who‘.

`-t‘
`--time‘
     Print last system clock change.


   An exit status of zero indicates success, and a nonzero value
indicates failure.

Linux -- who whoami

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.