1. 程式人生 > >Linux用戶登錄信息

Linux用戶登錄信息

用戶名 CP 3.6 默認 登錄系統 put com history sharp

1.用戶登錄日誌信息

  • /var/run/utmp:記錄當前正在登錄系統的用戶信息,默認由who和w記錄當前登錄用戶的信息,uptime記錄系統啟動時間;
  • /var/log/wtmp:記錄當前正在登錄和歷史登錄系統的用戶信息,默認由last命令查看;
  • /var/log/btmp:記錄失敗的登錄嘗試信息,默認由lastb命令查看

2.查看用戶登錄命令

w:查看當前登入系統的用戶信息及用戶當前的進程

[root@H0f ~]# w
 22:03:33 up 29 days,  4:47,  1 user,  load average: 0.00, 0.01, 0.05
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
root     pts/0    58.212.128.136   21:57    5.00s  0.00s  0.00s w

last:當前和曾經登入系統的用戶信息

[root@H0f ~]# last
root     pts/0        58.212.128.136   Wed Jun 13 21:57   still logged in   
root     pts/0        58.212.128.136   Tue Jun 12 23:32 - 00:11  (00:38)    
root     pts/0        171.35.57.52     Thu May 31 12:50 - 16:19  (03:29)    
root     pts/0        171.35.58.117    Mon May 28 21:07 - 21:37  (00:29)    
root     pts/1        180.169.225.186  Fri May 25 17:17 - 18:23  (01:05)    
root     pts/0        180.169.225.186  Fri May 25 16:58 - 18:23  (01:24)    
root     pts/1        180.169.225.186  Fri May 25 15:10 - 16:32  (01:21)    
root     pts/0        180.169.225.186  Fri May 25 09:45 - 16:32  (06:46)    
root     pts/0        112.64.60.8      Fri May 25 00:18 - 00:25  (00:06)    
root     pts/0        180.169.225.186  Thu May 24 10:29 - 21:35  (11:05) 

who:當前用戶登錄信息

[root@H0f ~]# who -q    #用戶登錄數量
root
# users=1
[root@H0f ~]# who -rH   #用戶登錄級別
NAME     LINE         TIME             IDLE          PID COMMENT
         run-level 3  2018-05-15 17:16
[root@H0f ~]# who        #當前用戶
root     pts/0        2018-06-13 21:57 (58.212.128.136)

user:顯示當前正在登入統的用戶名

[root@H0f ~]# users
root

3.操作記錄:history

[root@H0f ~]# history 
   14  config_file:/etc/redis/6379.conf
   15  # Clients
   16  connected_clients:26
   17  client_longest_output_list:0
   18  client_biggest_input_buf:14
   19  blocked_clients:0
   20  # Memory
   21  used_memory:1507720
   22  used_memory_human:1.44M
   23  used_memory_rss:1908736
   24  used_memory_peak:1585688
   25  used_memory_peak_human:1.51M
   26  used_memory_lua:654336
   27  mem_fragmentation_ratio:1.27
   28  mem_allocator:jemalloc-3.6.0
   29  # Persistence

  

Linux用戶登錄信息