LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices


Reply
  Search this Thread
Old 06-02-2005, 09:10 PM   #1
stefaandk
Member
 
Registered: Jun 2005
Distribution: Centos
Posts: 215

Rep: Reputation: 30
Looking for .login file on Fedora


I've been given the following tip to track logins on the system but I don't seem to have a .login and .logout file sitting on Fedora 2


TRACKING OF LOGINS AND LOGOUTS


In the .login file add the commands:
------------------------------------

echo login time `date` >> .daylogs/masterlog

grep -i "sun" .daylogs/masterlog > .daylogs/sunday.log grep -i "mon" .daylogs/masterlog > .daylogs/monday.log grep -i "tue" .daylogs/masterlog > .daylogs/tuesday.log grep -i "wen" .daylogs/masterlog > .daylogs/wensday.log grep -i "thu" .daylogs/masterlog > .daylogs/thursday.log grep -i "fri" .daylogs/masterlog > .daylogs/friday.log grep -i "sat" .daylogs/masterlog > .daylogs/saturday.log


In the .logout file add this line
-----------------------------------

echo logout time `date`>> .daylogs/masterlog

This script assumes you have a hidden
directory called .daylogs this helps keep it out of sight and away from prying eyes and if you keep root ownership of the directory change the mode to:

chmod 744 .daylogs

This will not allow anyone to get in to the directory to look around.
 
Old 06-03-2005, 08:27 AM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
.login and .logout are files that would be created in each user's home directory. They are basically just script files that get sourced at login time. If you are trying to track this for all users you might want to put it into /etc/csh.login and /ec/csh.logout as those are sourced by all users. That way you wouldn't have to add anything to each user.

Having said that please note that .login and .logout are used only by people that use csh or tcsh as their shell. People using bash (the default in most Linux distros) use different files (.profile and others). You'll want to verify which shell the user accounts are using. (Each user can have a different one.)

If you put it in /etc/csh.login you should probably modify it to have:

if [ ! -d $HOME/.daylogs ]
then mkdir $HOME/.daylogs
fi
echo login time `date` >> .daylogs/masterlog

The above will check to be sure the directory exists and if not will create it. If you're really trying to log users though you might want to consider putting this log somewhere OUTSIDE their home directory so that they don't see it with a simple ls -la of the home directory. You'd then want to add a username componet to distinguish from other users like so:

echo login time `date` $LOGNAME >> .daylogs/masterlog

Going on to the rest of what you wrote - note that the individual "grep" commands you're showing should be on separate lines or separate with semi-colons:
grep -i "sun" .daylogs/masterlog > .daylogs/sunday.log ; grep -i "mon" .daylogs/masterlog > .daylogs/monday.log ...

My advice would be separate lines to make it easier to read later.

However if you run the grep on every login its going to duplicate information the daylogs. You'd need to work out a more sophisticated grep tha only got the most recent information. Personally I don't see the value in the daylogs. Any time you need to see information for a specific day you can grep it fom he masterlog from the command line just by tryping the grep command.
 
Old 06-03-2005, 09:52 AM   #3
stefaandk
Member
 
Registered: Jun 2005
Distribution: Centos
Posts: 215

Original Poster
Rep: Reputation: 30
Thanks a heap for all that info, most usefull!
 
  


Reply



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 read .chm file in fedora, can't mount ntfs file system ishti_du Linux - Newbie 12 03-06-2007 03:27 AM
Where is Fedora login screen satimis Fedora 5 04-24-2005 03:58 AM
.login file tuananhbirm Linux - General 2 01-24-2005 07:20 PM
Change Fedora Login Screen to KDE login screen ada601 Linux - Software 2 08-15-2004 05:07 PM
fedora won't boot or let me login moschi Linux - Newbie 11 07-14-2004 04:41 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat

All times are GMT -5. The time now is 12:27 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
Open Source Consulting | Domain Registration