Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
[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

share|improve this question
What are the permissions on the parent directory? See Why can rm remove read-only files? – ire_and_curses Oct 2 '12 at 0:43
Similar to question: Why can't I delete this file as root? . Suggestion: unix.stackexchange.com/a/206595/92974 – Magnus May 31 at 16:35
up vote 9 down vote accepted

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).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.