How to edit sudoers file without errors
APPLIES TO : Solaris , Linux
ISSUE : Wrong Sudoers entry will cause errors to administrative operation.
GOAL : edit the sudoers without any error OR verify the sudoers file before editing it
SOLUTION : Copy the sudoers file to /tmp, update the changes, verify for correction using visudo command, if no error reported deploy the file to /etc/sudoers.
Follow the below steps.
1. Copy the file to /tmp directory
APPLIES TO : Solaris , Linux
ISSUE : Wrong Sudoers entry will cause errors to administrative operation.
GOAL : edit the sudoers without any error OR verify the sudoers file before editing it
SOLUTION : Copy the sudoers file to /tmp, update the changes, verify for correction using visudo command, if no error reported deploy the file to /etc/sudoers.
Follow the below steps.
1. Copy the file to /tmp directory
$ sudo cp /etc/sudoers /tmp/sudoers.tobe
2. Edit the copied sudoers file and made the required changes.
$ vi /tmp/sudoers.tobe
“enter the commands you wish to add”
2. Edit the copied sudoers file and made the required changes.
$ vi /tmp/sudoers.tobe
“enter the commands you wish to add”
3. Run the below command to verify the new file for errors
$/usr/sbin/visudo -c -f /tmp/sudoers.tobe
The output should as below
“/tmp/sudoers.tobe file parsed OK”
If you get parse error as below, please check for corrections on the newly added entries.
“>>> sudoers file: syntax error, line 132 <<<
parse error in /tmp/sudoers.tobe near line 132”
4. Take a copy of existing sudoers file
$sudo cp -p /etc/sudoers /etc/sudoers.`date +%Y-%m-%d-%H%M`
5. Change the permission of the new file
$sudo chmod 440 /tmp/sudoers.tobe
6. Copy the new file to /etc/sudoers
$sudo cp /tmp/sudoers.tobe /etc/sudoers
7. Verify the suoders functionality
$sudo –l
7. Delete the temporary file
$sudo rm /tmp/sudoers.tobe
~Judi~
No comments:
Post a Comment