Sign up ×
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.

I have a folder myfolder with lots of files and directories as follows:

-rwxrwx--x user1  user1   .
-rwxrwx--x root   root    ..
-rw-rw---- user1  user1   file1
-rw-rw---- user1  user1   file2
-rwxrwx--x user1  user1   dir1

I'd like to have a user: master who is able to remove all the files and folders. Be able to do:

rm -fr myfolder/*

Doing the following does not solve the problem:

chown user1:master myfolder

Because the user don't have write permissions in the subfolders. The subfolders are written by user1 randomly.

I can't change the permissions / owners of those files in a one time operation. If I do that user1 won't be able to create/edit files anymore.

What do you recommend?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

I would suggest to use ACLs, i.e., something like setfacl -R -m u:master:rwX -m d:u:master:rwX ./myfolder, where especially the second part d:u:master:rwX is relevant here since it means that any new files created in the myfolder directory will get rwX permissions for the user master.

share|improve this answer

Ok, lets do this so...

Create special group.

user1:~$ sudo groupadd test

Make user1 and master members

user1:~$ sudo usermod -a -G test user1
user1:~$ sudo usermod -a -G test master

Change myfolder dir's group and permissions recursively

user1:~$ chown -R user1:test myfolder
user1:~$ chmod -R 774 myfolder

Then you could remove all myfolder content as you want.

The recursive option allows user master to also modify myfolder's content, if you only want to rm files, with the simple read-write permissions to the dir you have

share|improve this answer
this wouldn't work since it's a one time operation. Any other proposal ? – Jordi P.S. Sep 24 at 14:59
@JordiP.S. then give w permission to other's section to the main dir – tachomi Sep 24 at 15:15
i just want master to be able to do so, not others – Jordi P.S. Sep 24 at 17:40

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.