This content on this page was written a long time ago. It might not be accurate or has opinions which have changed/evolved over time.

published on in Linux
tags: AT_FDCWD chmod Linux permission denied rm

Permission Denied

Update: The problem is solved now, it was because the parent directory had the +i flag set.

I ran into a weird problem today. I was cleaning up disk space and ran into a file that refused to delete.

geekbox:/media/7/ # rm file.iso

rm: cannot remove `file.iso’: Permission denied

No problem, huh? Did everything I could think of:

geekbox:/media/7/ # rm -f file.iso


**geekbox:/media/7/ # **chmod 777 file.iso

**geekbox:/media/7/ # **chown root:root file.iso

geekbox:/media/7/ # rm -f file.iso

rm: cannot remove `file.iso’: Permission denied

Filesystem problems?

geekbox:/media/7/ # fsck -f /dev/sdc2

7: 194131/31514624 files (0.3% non-contiguous), 119735268/126050006 blocks

Corrupted file?

geekbox:/media/7/ # dd if=file.iso of=/dev/null

7472920576 bytes (7.5 GB) copied, 302.342 s, 24.7 MB/s

Immutable bit set?

geekbox:/media/7/ # lsattr file.iso

————-e- file.iso

strace points me to this:

unlinkat(AT_FDCWD, “file.iso”, 0) = -1 EACCES (Permission denied)

I got my disk space back at least,

geekbox:/media/7/ # echo “” > file.iso

But now I’m stuck with a file I don’t know what to do with.