Screen Lock and unlock time

General support questions
Post Reply
rahulM
Posts: 2
Joined: 2021/02/05 06:49:47

Screen Lock and unlock time

Post by rahulM » 2021/02/05 07:11:07

Hello,

How can I get the screen lock and unlock time in Centos 7

Is secure log contained the information for the same?

"first successful unlock timing of every logged user" is what I am looking for.

pjwelsh
Posts: 2632
Joined: 2007/01/07 02:18:02
Location: Central IL USA

Re: Screen Lock and unlock time

Post by pjwelsh » 2021/02/10 14:25:32

Is there a chance to clarify the setup you may have for users? I'm a little confused on the, "first successful unlock timing of every logged user" part.
Does "every logged user" indicate the system in question has multiple ssh connections coming in or are you running some "linux terminal server"/RDP/VNC/NX connections or is what you are asking about just a workstation with one or more users logged in?
For simple ssh connections, I don't know of a "lock" per-say, but the "last" command does give login/logout info.
For Linux workstation and a GUI session that gets more "fun" since I don't know if that information is actually stored/logged anywhere for past reporting purposes (maybe a more knowledgeable person can help provide this). However, the current user state can be evaluated with the "loginctl" command via two parts:
This provides the list of logged in users (ignore the "gdm" user):

Code: Select all

loginctl list-sessions
SESSION  UID USER SEAT  TTY 
      2 1001 USERX   seat0 tty2
     c1   42 gdm  seat0 tty1
Then use the session number to get the "Idle*" or "Locked*" information from:

Code: Select all

loginctl --no-pager -a show-session 2
The beginnings of a scripted version could be like:

Code: Select all

for session in $(loginctl --no-legend list-sessions | grep -v gdm | awk '{print $1}'); do
  loginctl --no-pager -a show-session $session ...

rahulM
Posts: 2
Joined: 2021/02/05 06:49:47

Re: Screen Lock and unlock time

Post by rahulM » 2021/02/11 07:28:55

Thanks for the reply buddy,

Q Is there a chance to clarify the setup you may have for users?

After connecting to a VPN, through Teradici application user is able to log in to their dedicated Linux system
Now every day at what time user logs in or unlock the screen as he already logged in that I want to know.

Post Reply