I'm trying to monitor the /etc/shadow file as the root user and perform a specific set of actions once a change is made to that file. I want to use inotifywait to do so. However, whenever I monitor that file the body of the bash script is skipped and the script just exits.
while inotifywait -e modify,close_write /etc/shadow
do
echo "it works"
done
If I do something like that the output is never printed and the code never remains in a loop. The exit code is 0. Anyone know if I need to configure something before or am I just doing something wrong? Using RedHat 8.2.
Edit: Can someone explain why using the attrib event for inotifywait is necessary for the /etc/shadow file over modify or close_write?