LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-23-2004, 12:22 AM   #1
lbn1124
LQ Newbie
 
Registered: Aug 2004
Posts: 3

Rep: Reputation: 0
How can I tell when someone logs into the stystem?


How do you write a shell script program that can tell when someone logs into the system? What are the outlined steps needed to accomplish this task?
 
Old 08-23-2004, 01:03 AM   #2
masand
LQ Guru
 
Registered: May 2003
Location: INDIA
Distribution: Ubuntu, Solaris,CentOS
Posts: 5,522

Rep: Reputation: 58
hi
when someone logs into the system
there is a entry done in the "utmp" file

so u need to keep a check on that file

it is found in
/var/run/utmp

regards
gaurav
 
Old 08-23-2004, 01:28 AM   #3
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,275

Rep: Reputation: 370Reputation: 370Reputation: 370Reputation: 370
Just to expand on what masand said, you can use the "last" command to see what users have logged on in the past, and the who or w commands to see who is currently logged onto your system. These programs use the utmp and wtmp files to do their jobs.
 
Old 08-23-2004, 01:32 AM   #4
masand
LQ Guru
 
Registered: May 2003
Location: INDIA
Distribution: Ubuntu, Solaris,CentOS
Posts: 5,522

Rep: Reputation: 58
if u do not want to use the who ,w command in ur shell script

u can write u r own C program t0 parse the utmp file(and use that in ur shell script)
there are utmp functions for that also

man utmp
will guide u
regards
gaurav
 
Old 08-23-2004, 01:12 PM   #5
lbn1124
LQ Newbie
 
Registered: Aug 2004
Posts: 3

Original Poster
Rep: Reputation: 0
How can I tell when someone logs into the stystem?

Thank you so very much. That information was right on target, however, could you give an example outline how to write the code that I need to write a progam that will get this done? I am new at Linux and this was a project that was given to me to do and I don't have a clue how to get started with it. My textbook is so vague and adds so very little input into exactly how to get the code written to accomplish this project


Quote:
Originally posted by btmiller
Just to expand on what masand said, you can use the "last" command to see what users have logged on in the past, and the who or w commands to see who is currently logged onto your system. These programs use the utmp and wtmp files to do their jobs.
 
Old 08-23-2004, 01:26 PM   #6
masand
LQ Guru
 
Registered: May 2003
Location: INDIA
Distribution: Ubuntu, Solaris,CentOS
Posts: 5,522

Rep: Reputation: 58
hi there
i have finished the program and
i am uploading the file to myproject site

masand.sourceforge.net

will keep uposted on that

regards
 
Old 08-23-2004, 01:30 PM   #7
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
It really depends on exactly what you want to do with the ionformation. For example, typing:

last

at the cmd line shows logins up to and including current logins. On my RH9 box, the latest (ie most recent) are at the top of the list. Current ie ongoing logins are marked as such.

Typing

who

at the cmd line just shows current sessions/users.
Both cmd have a list of optional params that will show related factoids about each seesion or types of sesssions etc. See the man(ual) pages:

man who

man last

First you need to decide exactly what information you require, then you can start thinking of writing a script if needed to mangle the info.
You can just capture it into a file by eg:

last > t.t

HTH
 
Old 08-23-2004, 01:43 PM   #8
lbn1124
LQ Newbie
 
Registered: Aug 2004
Posts: 3

Original Poster
Rep: Reputation: 0
Thanks Chris,
Yes, what I would like to do is capture the information needed to determine the date and time of logon of a certain user on a given day; then write a script program that utilizes the captured information and print it on demand.
 
  


Reply


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
Ubuntu logs on, then logs back off generallee5686 Ubuntu 0 10-20-2005 02:11 PM
Firewall logs in logs and terminal... robbow52 Debian 7 11-20-2004 08:13 PM
Firefox logs user out? Where are error logs? case1984 Linux - General 0 10-09-2004 03:22 PM
Separate firewall logs and general logs dominant Linux - General 3 04-20-2004 02:26 AM
Apache logs - ???Linux logs??? mylo2003 Linux - General 3 08-07-2003 05:49 PM


All times are GMT -5. The time now is 06:41 AM.

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