Skip to main content

Posts

Showing posts with the label logs

Analyzing Linux User Activities

If you want to analyze which users are logged in, how long they logged in, which commands they have executed etc., you can use below commands and methods. Login Logs Login log files are stored in following locations: /var/log/wtmp – the login & logout history of users, as well as system boots and shutdowns. /var/run/utmp – currently logged in users. /var/log/btmp – failed login attempts. /var/log/lastlog - information about the last successful logins. No need to check these log files manually. You can instead use below commands. who and w commands who : prints information about users who are currently logged in. who command uses /var/run/utmp file by default. who #username #login time #remote hostname/ip address userX pts/0 2025-03-07 15:14 (111.111.33.111) Usernames and the number of currently logged on users: who -q # usernames of currently logged in users userX userY # the number of currently logged in users users=2 who co...