1 顯示上次登錄的用戶信息列表,包括(登錄時間、退出時間、登錄ip):
[sywu@wusuyuan ~]$ last
root pts/1 192.168.1.3 Wed Aug 27 22:08 still logged in
sywu pts/0 192.168.1.3 Wed Aug 27 21:52 still logged in
reboot system boot 2.6.32-431.3.1.e Wed Aug 27 21:51 - 22:12 (00:21)
root pts/0 192.168.1.3 Mon Aug 25 23:03 - down (00:11)
root tty1 Mon Aug 25 22:48 - down (00:26)
reboot system boot 2.6.32-431.3.1.e Mon Aug 25 22:47 - 23:15 (00:27)
root tty1 Mon Aug 25 19:32 - down (00:00)
reboot system boot 2.6.32-431.3.1.e Mon Aug 25 19:23 - 19:32 (00:09)
root pts/2 192.168.1.3 Sun Aug 24 22:17 - 22:36 (00:18)
sywu pts/0 192.168.1.3 Sun Aug 24 22:13 - down (00:22)
2 顯示上次用戶登錄信息(僅僅是上次),包括(登錄時間、登錄IP):
[root@wusuyuan ~]# lastlog --help
Usage: lastlog [options]
Options:
-b, --before DAYS PRint only lastlog records older than DAYS
-h, --help display this help message and exit
-t, --time DAYS print only lastlog records more recent than DAYS
-u, --user LOGIN print lastlog record of the specified LOGIN
[root@wusuyuan ~]# lastlog
用戶名 端口 來自 最后登陸時間
root pts/2 192.168.1.3 日 8月 24 22:17:05 +0800 2014
gdm **從未登錄過**
ntp **從未登錄過**
saslauth **從未登錄過**
postfix **從未登錄過**
pulse **從未登錄過**
sshd **從未登錄過**
tcpdump **從未登錄過**
vboxadd **從未登錄過**
sywu pts/0 192.168.1.3 日 8月 24 22:13:52 +0800 2014
lanston pts/1 192.168.1.100 日 6月 8 17:08:10 +0800 2014
3.上次登錄失敗的用戶信息:
[sywu@wusuyuan ~]$ sudo lastb
root ssh:notty 192.168.1.3 Wed Aug 27 22:16 - 22:16 (00:00)
root ssh:notty 192.168.1.3 Thu Aug 21 20:18 - 20:18 (00:00)
btmp begins Thu Aug 21 20:18:11 2014
4.誰登錄了當前系統(包括IP、登錄時間):
[root@wusuyuan ~]# who --help
用法:who [選項]... [ 文件 | 參數1 參數2 ]
顯示當前已登錄的用戶信息。
-a, --all 等于-b -d --login -p -r -t -T -u 選項的組合
-b, --boot 上次系統啟動時間
-d, --dead 顯示已死的進程
-H, --heading 輸出頭部的標題列
-l,--login 顯示系統登錄進程
--lookup 嘗試通過 DNS 查驗主機名
-m 只面對和標準輸入有直接交互的主機和用戶
-p, --process 顯示由 init 進程衍生的活動進程
-q, --count 列出所有已登錄用戶的登錄名與用戶數量
-r, --runlevel 顯示當前的運行級別
-s, --short 只顯示名稱、線路和時間(默認)
-T, -w, --mesg 用+,- 或 ? 標注用戶消息狀態
-u, --users 列出已登錄的用戶
--message 等于-T
--writable 等于-T
--help 顯示此幫助信息并退出
--version 顯示版本信息并退出
[root@wusuyuan ~]# who -a
系統引導 2014-08-24 22:11
運行級別 3 2014-08-24 22:11
登錄 tty1 2014-08-24 22:13 1996 id=1
登錄 tty2 2014-08-24 22:13 1998 id=2
登錄 tty3 2014-08-24 22:13 2000 id=3
登錄 tty4 2014-08-24 22:13 2002 id=4
登錄 tty5 2014-08-24 22:13 2008 id=5
登錄 tty6 2014-08-24 22:13 2010 id=6
sywu + pts/0 2014-08-24 22:13 00:11 2011 (192.168.1.3)
root + pts/2 2014-08-24 22:17 . 2158 (192.168.1.3)
5.登錄的用戶當前在做什么:
[root@wusuyuan ~]# w --help
w:無效選項 -- -
usage: w -hlsufV [user]
-h skip header
-l long listing (default)
-s short listing
-u ignore uid of processes
-f toggle FROM field (default on)
-V display version
[root@wusuyuan ~]# w
22:28:03 up 16 min, 2 users, load average: 0.01, 0.02, 0.02
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
sywu pts/0 192.168.1.3 22:13 13:21 0.07s 0.01s rlwrap sqlplus / as sysdba
root pts/2 192.168.1.3 22:17 0.00s 0.13s 0.00s w
6.顯示用戶登錄的時間:
[sywu@wusuyuan ~]$ ac #總的
total 115.46
[sywu@wusuyuan ~]$ ac -p
lanston 2.30
root 11.35
sywu 101.83
total 115.49
新聞熱點
疑難解答