How to delete file with no write permissions for any user?

I find myself in a strange situation where a script wrote files with the following permissions:

-r-------- 1 user1 user1 file1 Dec 24 14:53
-r-------- 1 user1 user1 file2 Dec 24 14:54
-r-------- 1 user1 user1 file3 Dec 24 14:55

How do I remove these files? I can't change the permissions of the files with chmod [neither with 'user1' nor as sudo/root].

[If it makes any difference, I am running ubuntu]


If you can't take ownership of them with the command:
sudo chown "${USER}" filename

And you can't delete them with the command:
sudo rm filename

Then you need to check if you can write at all to the partition.

If you can change other files on the partition, but not those files, then you probably have one of the following:

  • Files with the immutable flag set
  • Filesystem errors
  • Read-only overlay-fs
  • Some weird corrupted ACL

or a kernel thread or a root-kit may be blocking writes to the files.


Removing a file means changing the directory containing them. The file's permissions (and its ownership, for that matter) are inconsequential.

So, if you have write permissions to the containing directory, a simple rm should work.

If you do not, you will have to chmod +w . first.