File in /etc/sudoers.d file not being read by sudo

Rick picture Rick · Feb 8, 2014 · Viewed 41.4k times · Source

I want to add a user in the sudoers file and I don't want to touch the original /etc/sudoers file, so I added a new file under directory /etc/sudoers.d.

The interesting thing is about the name of the newly added file. Initially, I named the file as sudoers.local, the file never got effective; then I renamed the file as customize, it got effective immediate. The file name sudoers.customize doesn't work either. It seems any file name containing sudoers doesn't work. Someone know the reason? In all three cases, the file has the proper permission -r--r-----.

The OS is 64 bits CentOS 6.5.

Answer

Jim Garrison picture Jim Garrison · Feb 8, 2014

From the sudoers man page:

The #includedir directive can be used to create a sudo.d directory that the system package manager can drop sudoers rules into as part of package installation. For example, given:

#includedir /etc/sudoers.d

sudo will read each file in /etc/sudoers.d, skipping file names that end in ‘~' or contain a ‘.' character to avoid causing problems with package manager or editor temporary/backup files.