2018年11月20日 星期二

[Linux 文章收集] Linux / Unix: Check Last Time User Logged In On The System

Source From Here 
Question 
I am a new Unix system admin. How do I find ouw who has recently use the Linux or Unix-like server? Which terminals they used, and when they logged in and out of the my server? 

You need to use last command. This command displays last logins of users and ttys. 

Listing the Last times a user logged in on server 
The syntax is as follows: 
// Show all login history
# last

// Show login history of specific user
# last [UserNameHere]
# last [option] [UserNameHere]

Example: Display Linux user last login 
To display when a user named ‘vivek’ last logged in to the system, type: 
$ last vivek
$ last vivek | less

Sample outputs: 
 

The output in this example tell us when user vivek last logged in. The output will go back for several months or more as last command searches back through the file /var/log/wtmp and displays a list of all users logged in (and out) since that file was created. 

Example: Display last reboot time 
The user reboot logs in each time the system is rebooted. Thus following command will show a log of all reboots since the log file was created: 
# last reboot | head
reboot system boot 3.10.0-327.el7.x Mon Jul 23 19:05 - 16:15 (119+21:10)
reboot system boot 3.10.0-327.el7.x Fri Jun 22 13:37 - 16:15 (151+02:38)
reboot system boot 3.10.0-327.el7.x Wed Feb 7 23:04 - 16:15 (285+17:11)
...


Supplement 
Linux / Unix: last Command Examples 
FAQ - How do I extract login history?

沒有留言:

張貼留言

[Git 常見問題] error: The following untracked working tree files would be overwritten by merge

  Source From  Here 方案1: // x -----删除忽略文件已经对 git 来说不识别的文件 // d -----删除未被添加到 git 的路径中的文件 // f -----强制运行 #   git clean -d -fx 方案2: 今天在服务器上  gi...