I've got a directory and a file in it, with the directory marked as read-only:
$ mkdir directoryname
$ touch directoryname/filename
$ chmod a-w directoryname
I cannot delete the file, even if pass the -f
flag to rm
:
$ rm -f directoryname/filename
rm: cannot remove `directoryname/filename': Permission denied
Is there a way to force rm
to delete this file? Obviously, I could temporarily give directoryname
write permissions, but I'm looking for a more convenient way.
I believe the underlying unlink
syscall fails in the same way. Is there a way to get around that?
chmod 755
which will allow you to write/delete but won't allow your group nor others. – YoMismo Aug 01 '14 at 11:31rm -f
, but not files in read-only directories. I'm just looking for a convenient one-line command, I know why it fails by default. – Flimm Aug 01 '14 at 12:21