ubuntu remove file with full permissions

2

I created a file in the /tmp/ directory. The file is owned by mysql user and has full permissions, i.e.

-rw-rw-rw- 1 mysql  mysql    16 Sep 23 12:44 artists.csv

Now I want to delete it, but get Operation not permitted error:

shimon@T61p:~$ rm /tmp/artists.csv 
rm: cannot remove ‘/tmp/artists.csv’: Operation not permitted

I only can delete this file using sudo.
I want to know why I cannot delete file which has all permissions for that using my user.

Output of getfacl artists.csv:

shimon@T61p:/tmp$ getfacl artists.csv
# file: artists.csv
# owner: mysql
# group: mysql
user::rw-
group::rw-
other::rw-

Shimon Rachlenko

Posted 2013-09-23T10:31:51.137

Reputation: 161

Could you post the output of getfacl artists.csv? – terdon – 2013-09-23T10:48:00.513

@terdon here it is. – Shimon Rachlenko – 2013-09-23T10:51:22.673

It should at least be possible to delete it as root! – FSMaxB – 2013-09-26T10:25:14.543

Answers

3

After googling around I found the issue:
The /tmp folder has the sticky bit special permission:

drwxrwxrwt  11 root root 36864 Sep 23 14:12 tmp

Note the t at the end of permissions - this means that the sticky bit is set. When the sticky bit is set, any user can create files, but only the owner of a file can delete it.labor-liber.org

From Ubuntu Support:

Within a directory upon which the sticky bit is applied, users are prevented from deleting or renaming any files that they do not personally own.

Shimon Rachlenko

Posted 2013-09-23T10:31:51.137

Reputation: 161

Ah, we found the same google results :). Well done. Remember to accept this answer so the question can be marked as answered. – terdon – 2013-09-23T11:52:22.140