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

2

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]

Dhara

Posted 2013-12-24T14:07:05.360

Reputation: 181

Did you ever sort this issue as I have the same problem. A program created a bunch of files for me that have no write permission for any user. I cant use chmod/chown/rm with sudo so am stuck. – chrismacp – 2015-10-22T11:52:22.157

Can you change the owner using chown username file? – Ali Hashemi – 2013-12-24T14:12:56.497

@Pazis No, I don't have permissions for that! It's a recursive problem :( – Dhara – 2013-12-24T14:16:42.167

I cannot see the problem: I can easily chmod my files, even when their permissions are just 400. And I can delete them. Your problem is elsewhere (disk mount, perhaps?). – MariusMatutiae – 2013-12-24T16:11:49.147

@MariusMatutiae - In your computer you will be the owner of the files so you won't find any problem in your system. – vishram0709 – 2013-12-24T17:01:05.690

Right. Are you telling me you are trying to erase someone else's files? – MariusMatutiae – 2013-12-24T17:01:46.207

@Dhara - What do you mean by its a recursive problem? Are these files created by you or someone else? – vishram0709 – 2013-12-24T17:12:37.383

Maybe your file is immutable? See man chattr, read about immutable (i) attribute. – AnonymousLurker – 2013-12-24T23:11:48.970

Answers

0

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.

sds

Posted 2013-12-24T14:07:05.360

Reputation: 1 600