简体   繁体   中英

How to know when users login linux machine?

I am pretty much new to linux programming. 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. See the man page for more information.

Read the manual page for utmp(5) and 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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