Re: [問題] 有辦法 Monitor 某隻檔案是哪個程式產生的嗎

看板Linux作者時間17年前 (2008/06/17 08:01), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/2 (看更多)
※ 引述《yjhuang.bbs@ptt.cc (特務J)》之銘言: > 請問, > 在 Linux 下,常常在某些資料夾會產生一些奇怪的檔案。 > 如果想知道,某隻檔案是哪個程式或process 產生的, > 有辦法做到嗎? > 謝謝 可以,一般要先啟動 audit 服務程式。比方 RHEL or Fedora 等系統先執行: /etc/init.d/auditd start 後續用 auditctl 新增 rule,像是: auditctl -w /tmp/test.txt -p w 後續只要有任何 test.txt 的寫入存取都會紀錄。 要查看就是用 ausearch,使用像是: ausearch -f /tmp/test.txt 執行輸出畫面: type=PATH msg=audit(1213643300.069:174): item=1 name="/tmp/test.txt" inode=37 dev=08:0a mode=0100644 ouid=0 ogid=0 rdev=00:00 type=PATH msg=audit(1213643300.069:174): item=0 name="/tmp/" inode=2 dev=08:0a mode=041777 ouid=0 ogid=0 rdev=00:00 type=CWD msg=audit(1213643300.069:174): cwd="/tmp" type=SYSCALL msg=audit(1213643300.069:174): arch=40000003 syscall=5 success=yes exit=3 a0=bf9b972e a1=8941 a2=1b6 a3=8941 items=2 ppid=30417 pid=31235 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts10 comm=touch" exe="/bin/touch" key=(null) type=SYSCALL msg=audit(1213643372.107:200): arch=40000003 syscall=301 success=yes exit=0 a0=ffffff9c a1=bf903734 a2=0 a3=bf903734 items=3 ppid=30417 pid=31455 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts10 comm="rm" exe="/bin/rm" key=(null) 所以可以透過 uid,euid 知道身份,exec 可以知道存取的程式。 還有興趣可以看看這篇: http://www.cyberciti.biz/tips/ linux-audit-files-to-see-who-made-changes-to-a-file.html -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 現代人普遍的現象: 「小學而大遺」、「捨本而逐末」 「以偏而概全」、「因噎而廢食」 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ※ Origin: SayYA 資訊站 <bbs.sayya.org> ◆ From: kendlee.sayya.org
文章代碼(AID): #18Llw-00 (Linux)
文章代碼(AID): #18Llw-00 (Linux)