How can I tell when someone logs into the stystem?
Linux - NewbieThis 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
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.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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:
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.