Shell – Understanding sudoers:

chmodshellsudo

I have a Unix script which creates a temporary log file, say tempfl.log.
When this file is created it has permission rw-r--r--.

There is a line

chmod 0440 /etc/sudoers tempfl.log 2>&1

But when the script is done the permission changes to r--r--r-- but it should be rw-r--r--. If I change the line to

chmod 0644 /etc/sudoers tempfl.log

The permissions are right for tempfl.log but it throws errors saying:

sudo: /usr/local/etc/sudoers is mode 0644, should be 0440

I do not understand what sudoers is doing and what is wrong.

Best Answer

Your script is changing the permission of 2 files, /etc/sudoers and tempfl.log. Split the command in two lines and you should be fine.

Related Question