Unable to delete file, even when running as root

Check the permissions of the directory. To delete a file inside it, it should be writable by you

chmod ugo+w .

and not immutable or append-only:

chattr -i -a .

Check with ls -la and lsattr -a.


I had a similar problem but had tried both permissions and chattr previously to no avail. Root in Terminal. CD to Directory.

However what worked for me was to check permissions of directory where troublesome file was located - if ok proceed to:

chmod ugo+w filename

this failed - then:

chattr -i -a filename 

which was accepted - then

chmod ugo+w 

which was accepted

rm filename

and it was gone.

Fedora 25 on hp workstation.


'sudo' can run the 'rm' command using the same user.group

NOTE: not sure if this will also work for ids like you have.

Example:

ls /path/to/dir_being_deleted
  drwxrwxrwx 2 nfsnobody nfsnobody   4096 Mar  8 06:55 .
  drwxrwxrwx 7 nfsnobody nfsnobody   4096 Mar  8 06:57 ..
  -rwxrwxrwx 1 nfsnobody nfsnobody      0 Mar  8 06:55 filename.txt

sudo -u nfsnobody -g nfsnobody rm -rf /path/to/dir_being_deleted