Search Our Database

Resolving ‘Operation Not Permitted’ Errors when modifying files in Linux

Last updated on |
by

Introduction

When attempting to delete a file via FTP, you may encounter the following error:

Error Message:  Operation not permitted

This issue can arise due to incorrect file ownership, insufficient permissions, or immutable file attributes. Follow the steps below to diagnose and resolve the problem.

 


Step-by-Step Troubleshooting

Step 1: Access the Server via SSH

Access your server via SSH:

ssh username@your_server_ip

Navigate to the directory containing the file:

cd /home/domain/xxxx/xxx/xxx

 

Step 2: Check for Immutable File Attributes

Some files may have immutable attributes preventing deletion. To check for this, run:

lsattr /domains/ips1/image/xxx.php

Example output:
—-i——e– xxx.php

If the file has the i (immutable) attribute, you need to remove it before deleting the file.

Solution: Remove the Immutable Attribute

sudo chattr -i /domains/ips1/images/xxx.php

Once the attribute is removed, you should be able to delete the file via FTP.

 

Step 3: Verify File Ownership and Permissions

Check the file owner and permissions:  Example output:
-rw-r–r– 1 root root 12345 Feb 12 12:34 xxx.php

Change ownership if necessary:

sudo chown yourftpuser:yourftpuser /domains/ips1/images/xxx.php


 

Conclusion

By following these steps, you should be able to resolve the Operation Not  Permitted   error when deleting a file via FTP. If the issue persists, verify that the directory permissions are correctly set and check for additional restrictions in the server configuration.
If you need more help, feel free to communicate with our support team at support@ipserverone.com.