Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.
[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
2  
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
add comment

1 Answer 1

up vote 7 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
add comment

Your Answer

 
discard

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.