Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • I don't understand that problem. It would be easier if you added to the question what you've already tried doing, which command you're using. For instance, to monitor any processes that accesses a file you can run auditctl -w /etc/passwd -p rwa, but I don't know if you've already tried that and what's missing. This command also shows the pid and process name that accessed the file. Also, I don't understand how sudo is related, since you say "doesn't matter if a cat or sudo cat". Commented Oct 25, 2022 at 9:55
  • Thanks for your response. The filewatch you mentioned was the easy part. What I need now is this: A user who issues this "sudo vim /etc/passwd" or "cat /etc/passwd" etc. shoud be logged...if a user issues a sudo command like this "sudo vim somefile" ...nothing should be logged. Commented Oct 25, 2022 at 10:05
  • You can see in the audit log this information in the auid field. See here: Records the Audit user ID. This ID is assigned to a user upon login and is inherited by every process even when the user's identity changes (for example, by switching user accounts with su -john). Commented Oct 25, 2022 at 11:35
  • Given that /etc/passwd will be accessed every time a user runs ps -fe, ls -l, top, etc, do you really want to scan through all of those logs? Commented Oct 25, 2022 at 12:27