Linux 下查看系統當前登錄用戶信息


當你新登錄一個主機,過着管理一個主機,這時候你就需要這些命令來進行查看了:

1. w : Show who is logged on and what they are doing.

    w [options] user [...]

常用命令:

    w -h --no-header

    w -u --no-current

    w -s :   Use the short format.  Don't print the login time, JCPU or PCPU times.

    w -i, --ip-addr : Display IP address instead of hostname for from field.

2. who : Show who is logged on

   who -a, --all 展示所有的; 相當於 使用 -b -d --login -p -r -t -T -u

3. users: Print the user names of users currently logged in to the current host

4. whoami : Print effective userid

    Print the user name associated with the current effective user ID.  Same as id -un.

5. last : last, lastb - show a listing of last logged in users

    last -a 

    last [options] [username...] [tty...]

last  searches  back  through the /var/log/wtmp file (or the file designated by the -f option) and displays a list of all users logged in
       (and out) since that file was created.  One or more usernames and/or ttys can be given, in which case last will  show  only  the  entries
       matching those arguments.  Names of ttys can be abbreviated, thus last 0 is the same as last tty0.

       When  catching  a  SIGINT  signal  (generated by the interrupt key, usually control-C) or a SIGQUIT signal, last will show how far it has
       searched through the file; in the case of the SIGINT signal last will then terminate.

       The pseudo user reboot logs in each time the system is rebooted.  Thus last reboot will show a log of all the reboots since the log  file
       was created.

       lastb is the same as last, except that by default it shows a log of the /var/log/btmp file, which contains all the bad login attempts.

 last reboot 展示所有的機器重新啟動的情況。

6. lastb:lastb is the same as last, except that by default it shows a log of the /var/log/btmp file, which contains all the bad login attempts.

    在root 權限下,使用 lastb 命令,將會顯示所有嘗試登錄失敗的情況。

保持更新,轉載請注明出處。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM