Home > Enterprise >  How to delete a file on ubuntu with another user?
How to delete a file on ubuntu with another user?

Time:08-04

I'm trying to create a file with a user. The file should be created in a manner that another user can delete it (I would be fine with just any user being able to delete it).

cd /tmp
> test
chmod 666 test
#make file owned by a different user and group
chown tomcat:tomcat test
rm -r test

Result:

rm: cannot remove 'test': Operation not permitted

What am I doing wrong? How do I have to create that file so another user is able to delete it?

CodePudding user response:

The /tmp directory is a "bit" special. It has the permissions 1777 which sets the sticky bit. You'll see that an ls -l / shows tmp with the permissions:

drwxrwxrwt  25 root root      12288 Aug  3 08:20 tmp/

That t means that it prevents anyone except the owner from removing files. You'll need to use a different directory. Additionally, the -r doesn't make sense for a file.

  • Related