How to solve "sudo: /etc/sudoers.d is world writable"? (3 Solutions!!)
Table of Contents
Introduction
In this tutorial, we will address the common issue of the error message "sudo: /etc/sudoers.d is world writable" that occurs in Linux systems. This warning indicates a security risk because the permissions on the /etc/sudoers.d
directory are set too loosely, potentially allowing unauthorized users to modify its contents. We will explore three effective solutions to resolve this issue.
Step 1: Check Current Permissions
Before making any changes, it's important to verify the current permissions of the /etc/sudoers.d
directory.
- Open your terminal.
- Run the following command to check the permissions:
ls -ld /etc/sudoers.d
- Observe the output. The permissions should ideally be
drwxr-xr-x
(755). If you seedrwxrwxrwx
(777), it means the directory is world writable.
Step 2: Change Permissions of the Directory
To fix the permission issue, you need to change the permissions of the /etc/sudoers.d
directory.
- In the terminal, execute the following command:
sudo chmod 755 /etc/sudoers.d
- This command sets the permissions to
rwxr-xr-x
, which restricts write access to the owner only.
Step 3: Verify Permissions Again
After changing the permissions, it's essential to verify that the changes have been applied correctly.
- Run the command again:
ls -ld /etc/sudoers.d
- Ensure the output now shows
drwxr-xr-x
(755). If it does, you've successfully resolved the issue.
Alternative Solutions
If the above steps do not resolve your issue or if you prefer different methods, here are two additional solutions:
Solution 1: Change Ownership of the Directory
- Change the ownership of the directory back to the root user:
sudo chown root:root /etc/sudoers.d
Solution 2: Check Other Permission Issues
- Sometimes, the problem may stem from files within the
/etc/sudoers.d
directory. Check the permissions of the files:ls -l /etc/sudoers.d
- Ensure that the files have the correct permissions set (e.g.,
644
).
Conclusion
The "sudo: /etc/sudoers.d is world writable" error can pose a security risk but is easily fixed by adjusting the permissions of the directory. Follow the steps outlined above to ensure that your system remains secure. If issues persist, consider checking ownership and permissions of individual files within the directory. Always remember to verify permission settings after making changes to prevent similar issues in the future.