Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Desktop
User Name
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.


  Search this Thread
Old 09-30-2009, 08:31 AM   #1
LQ Newbie
Registered: Apr 2006
Posts: 7

Rep: Reputation: 0
How to track the user sessions

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.

Thanks in advance.

Old 09-30-2009, 09:54 PM   #2
LQ Newbie
Registered: Jul 2008
Posts: 1

Rep: Reputation: 0
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.
Old 10-01-2009, 01:00 AM   #3
LQ Newbie
Registered: Apr 2006
Posts: 7

Original Poster
Rep: Reputation: 0
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.
Old 10-07-2009, 09:02 AM   #4
LQ Newbie
Registered: Apr 2006
Posts: 7

Original Poster
Rep: Reputation: 0
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.
Old 12-02-2009, 01:07 AM   #5
Registered: Aug 2008
Posts: 79
Blog Entries: 1

Rep: Reputation: 16
Question i want to know ur linux script

hello hiarunn
can u tell me ur linux shell script for me ..........



login, logout, script

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get a Bash to count user sessions without WC Bamahut Programming 5 07-16-2008 07:52 AM
record of user sessions PirateJack Linux - Newbie 5 04-03-2006 03:25 PM
how to track all the live sessions in php? xudingding Linux - Software 3 02-15-2006 11:55 AM
track sudo user mikeshn Linux - General 2 10-28-2003 08:12 PM > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 12:31 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration