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.
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.
You can find the sudoers file in “/etc/sudoers”. Use the “ls -l /etc/” command to get a list of everything in the directory.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With