Auto

Thursday, 28 November 2024

Fix 'Operation not permitted' Error for /etc/resolv.conf

How to Fix 'rm: cannot remove '/etc/resolv.conf': Operation not permitted'

If you're using Ubuntu and encounter an error when trying to update or delete the /etc/resolv.conf file, even with root privileges, the issue may be due to the file being marked as immutable.

Error

rm: cannot remove '/etc/resolv.conf': Operation not permitted
        

Prerequisites

  • Access to a terminal or command line.
  • A user account with sudo or root privileges.

Steps to Fix the Issue

Step 1: Check if the File is Immutable

Run the following command to check the attributes of the /etc/resolv.conf file:

lsattr /etc/resolv.conf
        

If the file is immutable, you'll see an output similar to this:

----i--------------- /etc/resolv.conf
        

Step 2: Remove the Immutable Flag

To remove the immutable attribute, use this command:

sudo chattr -i /etc/resolv.conf
        

Step 3: Verify the Change

Check the file's attributes again to ensure the i flag has been removed:

lsattr /etc/resolv.conf
        

The output should now look like this:

-------------------- /etc/resolv.conf
        
Back to Top

Published by YourWebsiteName | Last Updated: Dec 9, 2020

No comments:

Post a Comment