Cannot delete a file - permission denied - why?
28,128
In order to delete a file, you must have write permissions on the directory that the file resides in. When you rm
a file it makes the unlink
system call which removes the name from the directory. This only deletes the file if it is the last remaining link to the inode.
You can find more information in unlink(2).
Author by
Radek
Updated on September 18, 2022Comments
-
Radek almost 2 years
[db2inst1][testing ~/sqllib/db2dump] rm db2diag.log rm: cannot remove `db2diag.log': Permission denied [db2inst1][testing ~/sqllib/db2dump] id uid=1002(db2inst1) gid=107(db2iadm1) groups=16(dialout),33(video),107(db2iadm1),108(db2fadm1),1001(eduserver) [db2inst1][testing ~/sqllib/db2dump] ll total 1381172 -rw-rw-rw- 1 root db2iadm1 1412931954 Oct 2 10:24 db2diag.log
Currently logged user (db2inst1) is part of db2iadm1 group that has w permission to the file I want to delete. But I am not able. Any idea why?
update - permission for parent directory
drwxr-sr-x 2 root db2iadm1 4096 Aug 22 14:39 db2dump
-
Admin over 11 yearsWhat are the permissions on the parent directory? See Why can
rm
remove read-only files? -
Admin about 8 yearsSimilar to question: Why can't I delete this file as root? . Suggestion: unix.stackexchange.com/a/206595/92974
-