Linux - DesktopThis forum is for the discussion of all Linux Software used in a desktop context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I'm using LDAP and kerberos for user authentication. All I want to know is how to track the users currently logged on from a common location. I was thinking of having a script to write the $USER,$HOSTNAME,login/logout time, hours used etc on a NFS mount, but don't know where to call the script so that it will be executed whenever an user logs in / logs out. I'm using Gnome desktop manager.
If you want to track who is logged in to your machine, just use the "w" command. To keep it updating you would use a command such as "watch -n2 w". This will show who is logged in, and what they are doing. It will update every 2 seconds "-n2" . To find out historically who has logged in, the "last" command will help you.
The command "w" or "last" is useful when you want to know who is currently logged into a particular system. But in my setup there are 250+ workstations. I should be able to see who logged into to each system. The output of the script/cmd should be something like below
Host User Login_time logout_time
------------------------------------
host1 userA 10:30 Still logged in
host2 userB 09.15 12:10
host3 userX 11.30 Still logged in
This should get updated everytime a user login/logout.
I found the way to do this. I wrote a simple shell script to log the hostname, user name and login/logout time to a plain text file and append the lines to /etc/X11/gdm/PostLogin/Default file to log when a user logs in and /etc/X11/gdm/PostSession/Default can be used when a user quits the session. The information can be directed to a text file on the network mount or to a remote database.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.