Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I figure out which process is changing the permissions of a file?

on a Debian server, I have the problem that something is changing the permissions on /dev/null every day at 6:20 (since 3 weeks). When I set the correct permissions, they are set back between a few minutes. Then I set it again and after that permissions stay correct until next day 6:20. It doesn't matter at which time I set the permissions.

share|improve this question
This Link talks about a monitoring tool inotify-tools, to monitor permission changes. Have a look! – Munai Das Udasin Aug 14 '14 at 13:42
that's not what i need, because i know when the file is changed. i need to know which Process (PID, Name) is changing the file. – user1008764 Aug 14 '14 at 14:04
what was the culprit? – Creek Aug 14 '14 at 15:16
For me, the culprit was /root/.nano_history symlinked to /dev/null. So everytime nano was used and wrote its history it attempted to correct the permissions... (I can imagine this happening with other programs in a similar setup) – Cobra_Fast Oct 27 '14 at 14:31
up vote 7 down vote accepted

Install auditd and run:

sudo auditctl -a exit,always -F arch=b64 -S fchmod -S chmod -S fchmodat \
  -F path=/dev/null -k dev-null-chmod
sudo auditctl -a exit,always -F arch=b32 -S fchmod -S chmod -S fchmodat \
  -F path=/dev/null -k dev-null-chmod

You'd find the culprit in the output of:

sudo ausearch -ik dev-null-chmod

You'll see the command name, pid and parent pid in there. If the command name is chmod, you'll probably want to know what ran that command. If the ppid is no longer there, you may want to also monitor all the process creation and/or executed commands with the audit system again or with bsd process accounting.

share|improve this answer
Fits my needs precisely, thank you very much! – user1008764 Aug 14 '14 at 14:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.