简体   繁体   English

如何知道用户何时登录linux机?

[英]How to know when users login linux machine?

I am pretty much new to linux programming. 我对linux编程非常陌生。 I want to create a log file with some info when a user just logs in. so where can I find an event or something when a user logs in? 我想在用户刚登录时创建带有一些信息的日志文件。那么,当用户登录时我在哪里可以找到事件或其他内容? is there any structure that has some flag when user logs in? 用户登录时是否有带有某些标志的结构?

Thanks 谢谢

The utmp and wtmp files contain last login data. utmpwtmp文件包含最后的登录数据。 See the man page for more information. 有关更多信息,请参见手册页。

Read the manual page for utmp(5) and getutent(3) 阅读utmp(5)getutent(3)的手册页

The files: 文件:

   /var/run/utmp
   /var/log/wtmp

contain information about who's currently using the system. 包含有关谁当前正在使用该系统的信息。 The wtmp file records all logins and logouts and the utmp file contains information of what kind of login it is, who logged in etc. wtmp文件记录所有登录和注销,而utmp文件包含有关登录类型,登录者等的信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM