nixCraft Linux Forum

nixCraft

Linux Tech Support Forum

Logging File Accesses

This is a discussion on Logging File Accesses within the Shell scripting forums, part of the Development/Scripting category; I have tried for quite some time now to work out a shell script on these lines. Actually came across ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Register FAQ Members List Calendar Forgotten your password? Mark Forums Read
  #1 (permalink)  
Old 11-06-2006, 07:11 AM
Junior Member
 
Join Date: Nov 2006
Posts: 2
Rep Power: 0
madz
Default Logging File Accesses

I have tried for quite some time now to work out a shell script on these lines. Actually came across this problem when i was going throught the commonly found abs-guide exercises
http://www.die.net/doc/linux/abs-gui...ngscripts.html


The script is to do the following:
********************************************
Log all accesses to the files in /etc during the course of a single day. This information should include the filename, user name, and access time. If any alterations to the files take place, that should be flagged. Write this data as neatly formatted records in a logfile.
*******************************************

Any help to get going in this direction will be great!

Thanks a lot
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 11-07-2006, 01:46 AM
rockdalinux's Avatar
Contributors
User
 
Join Date: May 2005
Location: Bangalore
My distro: RHEL, HP-UX, Solaris, FreeBSD, Ubuntu
Posts: 581
Rep Power: 7
rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough
Default

Do you really wanna write script for this stuff? You can use automated tool such as tripwire. But let me know if you need script logic. I can provide you simple script logic.
__________________
Rocky Jr.
You may have my body & soul, but you will never touch my pride!

If you have knowledge, let others light their candles at it.

Certified to work on HP-UX / Sun Solaris / RedHat
Reply With Quote
  #3 (permalink)  
Old 11-08-2006, 02:54 AM
Junior Member
 
Join Date: Nov 2006
Posts: 2
Rep Power: 0
madz
Default

Thanks rockdalinux for your help.

I could figure out the logic but was getting stuck on how to do it using shell scripting since unlike c programming you cannot get into the internal functions of the kernel to work on fd ( or am i mook on this?)

However i found the command that would help me going in this direction.

Its pretty simple once i got hold of the command and the switch.

In this case to get access of the /etc files and the users who did it, i used the lsof command as shown below:

lsof +D /etc

One can use +d if you do want only listing of the files at the first level only

Now l i can filter the data with awk and sed. :P

But i am thinking if i could write a deamon for the same so that the script runs continously and logs the data to a log file. I am still an novice in writing deamons and wrappers with shell scripts .

Now time to work on it!

Thanks rockdalinux for sharing your thoughts on my problem
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
Read arguments from a file and pass them to binary file AHJ Shell scripting 1 10-31-2007 07:04 PM
Error while logging in the linux system vaibhav.kanchan Getting started tutorials 2 07-19-2007 10:27 PM
Call Logging and Asset Mgmnt SW ricc Linux software 1 06-29-2007 02:45 AM
convert pdf (ppt file) into wordppt file sureshbup Linux software 1 12-07-2006 04:51 PM
MRTG stops logging nathan86 Linux software 12 03-23-2005 08:14 PM


All times are GMT +5.5. The time now is 06:33 PM.


Powered by vBulletin® Version 3.7.4 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36