Super User is a question and answer site for computer enthusiasts and power users. 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

Below shows a file, /tmp/testfile, owned by user1 with group changed to wheel that also includes user2. The file has rw permission for the group. So shouldn't any member of the group be able to delete it? The example output below shows that user2 is not able to delete the file. Why?

[user2@files ~]$ ls -l /tmp/testfile
-rw-rw-r-- 1 user1 wheel 0 Jul 18 18:54 /tmp/testfile
[user2@files ~]$ groups
user2 wheel
[user2@files ~]$  rm /tmp/testfile
rm: cannot remove `/tmp/testfile': Operation not permitted
share|improve this question
possible duplicate of Why can't I delete a file where I have group write permissions on? – Hastur Jul 18 '14 at 22:52
up vote 24 down vote accepted

First, you're looking at the wrong permissions. When you move/rename/delete a file, you're only modifying the parent directory – the file's own permissions are not checked. You only remove an entry from the directory's list of files. Therefore you should check the permissions of the parent directory (in this case /tmp).

$ ls -ld /tmp
drwxrwxrwt 15 root root 460 Jul 19 15:18 /tmp/

Second, /tmp is special. On practically all systems, it's writable by anyone (ugo=rwx), so at first glance, it looks like anyone could rename or delete any file in it. This would of course make it easy (well, even easier) to create problems for other users, therefore /tmp always has the "sticky" aka "restricted deletion" mode set (o+t). With this mode set, only the file's owner can move or delete files in that directory, regardless of any permissions.

(On GNU coreutils, the chmod(1) manual page has a section about the "restricted deletion flag or sticky bit".)

share|improve this answer
I'm facing the same issue due to second point of special sticky permission. I tried to remove it chmod o-t /tmp and then re-tried to delete the file, but it is still complaining the same. – Shashank Agrawal Mar 23 '15 at 11:43
Not only the file owner can delete files under said directory, but also root and the owner of the directory (e.g. /tmp). – wulfgarpro Dec 9 '15 at 22:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .