微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

linux-查找哪个用户在UNIX上什么时间访问了特定文件

有人可以建议我使用任何命令,以查看哪个用户在UNIX上什么时间访问了特定文件.我知道历史记录命令会列出以前触发的命令,但其中不包括“谁”触发的命令和触发时间.

解决方法:

使用Linux审核特定文件

http://www.cyberciti.biz/tips/linux-audit-files-to-see-who-made-changes-to-a-file.html

假设我有一个文件(让它为$HOME / an_important_file.txt),并且我想监视对该文件的所有访问.首先为其设置审核规则:

$sudo auditctl -w $PWD/an_important_file.txt -p warx -k watch_an_important_file

并检查了审核日志:

$sudo ausearch -k watch_an_important_file
----
time->Thu May 12 10:54:16 2016
type=CONfig_CHANGE msg=audit(1463039656.913:278): auid=500 ses=1 subj=unconfined_u:unconfined_r:auditctl_t:s0-s0:c0.c1023 op="add rule" key="watch_an_important_file" list=4 res=1

然后,我通过触摸修改文件($touch $HOME / an_important_file.txt).我正在再次检查审核日志:

$sudo ausearch -k watch_an_important_file
----
time->Thu May 12 10:54:16 2016
type=CONfig_CHANGE msg=audit(1463039656.913:278): auid=500 ses=1 subj=unconfined_u:unconfined_r:auditctl_t:s0-s0:c0.c1023 op="add rule" key="watch_an_important_file" list=4 res=1
----
time->Thu May 12 10:56:42 2016
type=PATH msg=audit(1463039802.788:291): item=1 name=(null) inode=535849 dev=fd:02 mode=0100664 ouid=500 ogid=500 rdev=00:00 obj=unconfined_u:object_r:user_home_t:s0 nametype=norMAL
type=PATH msg=audit(1463039802.788:291): item=0 name="/home/Sergey.Kurenkov/" inode=524289 dev=fd:02 mode=040700 ouid=500 ogid=500 rdev=00:00 obj=unconfined_u:object_r:user_home_dir_t:s0 nametype=PARENT
type=CWD msg=audit(1463039802.788:291):  cwd="/usr"
type=SYSCALL msg=audit(1463039802.788:291): arch=c000003e syscall=2 success=yes exit=3 a0=7fff6d986060 a1=941 a2=1b6 a3=3149b8f14c items=2 ppid=4852 pid=10022 auid=500 uid=500 gid=500 euid=500 suid=500 fsuid=500 egid=500 sgid=500 fsgid=500 tty=pts1 ses=1 comm="touch" exe="/bin/touch" subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 key="watch_an_important_file"

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐