Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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.

like image 222
Rick Avatar asked Feb 08 '14 01:02

Rick


People also ask

How do I fix a sudoers file error?

The result can be an impaired instance that can't run sudo su or commands that require privileged user access. To fix this syntax error, stop the instance, detach its root volume, attach it to a recovery instance, mount the root volume as a secondary volume, and then revert the changes to the sudoers file.

How do I view sudoers D?

You can find the sudoers file in “/etc/sudoers”. Use the “ls -l /etc/” command to get a list of everything in the directory.

How do I read a sudoers file?

Run sudo -V to see the sudo configuration options, including the path to the sudoers file. If your environment has an automatic mechanism for distributing a single sudoers file to the entire network, you can use that one file and don't need to import multiple files.

How do you fix is not in the sudoers file this incident will be reported?

The error message looks like this: $ sudo -i [sudo] password for linuxconfig: linuxconfig is not in the sudoers file. This incident will be reported. In order to fix the error, all we need to do is add our user to the correct group.


1 Answers

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.

like image 50
Jim Garrison Avatar answered Sep 20 '22 15:09

Jim Garrison