Avatar of Balbir Singh
Balbir Singh
Flag for United States of America asked on

How to monitor char file permission using monit

I am wondering how can we monitor the permission on char file using monit application

I have below char file


and below monitrc config

check file dev_null with path /dev/null
if failed permission 666 then exec "chmod 666 /dev/null" as uid root and gid wheel

But it doesn't seems to work when file /dev/null has permission 600

I really appreciate any help on that.
LinuxUnix OS

Avatar of undefined
Last Comment
David Favor

8/22/2022 - Mon

/dev/null is in short considered a trash bin.
anything sent here is discarded.

not sure I understand what you are asking /dev/null is a "system device"

It should not be changing permissions.
Balbir Singh

Hi Arnold,

I have observed that file permission on /dev/null keeps on changing and I guess it is due to some package or process which cause issue to my other application which needs write permission to trash few things. So I want to monitor its permission using monit and if it is not there then correct the permission.

Please let me know if you have any recommendation on how to do it.

Best Regards!

you should double check what cron jobs you have or scripts that run chmod on /dev/null
I do not believe there is any system level task, or mechanism that will be doing that.

not sure monit is in a position to monitor a character device.  usually I think monit can monitor fles or folders.

if you have this issue, setup a cron under root to run every minute to issue the chmod 666 /dev/null
* * * * * chmod 666 /dev/null >/dev/null

also not sure which linux system you have, but ownership of /dev/null should commonly be by root with root or other as the group.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
David Favor

View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.