0

I want a folder to have 777 permission and every time a new file or folder gets created inside that should have the same user and group with 777 permission.
I tried the following but it does not get executing permission for the new files inside the folders.

sudo chmod -R 2777 new_folder
ll 
drwxrwsrwx 2 test test 4096 Oct 11 08:30 new_folder
cd new_folder
touch new_file
ll new_file
-rw-rw-r-- 1 test test 0 Oct 11 08:31 new_file

I want it to have -rwxrwxrwx whenever i create new folder or files inside that. How can this be done?

6
  • if you add umask as tag this may yield an answer Oct 11, 2014 at 8:52
  • how to do that? Please give me the command
    – James
    Oct 11, 2014 at 8:54
  • umask will apply to all files a user creates, not to a specific directory. Please tell what you want to accomplish, maybe there is a better way than what you ask for. Oct 11, 2014 at 8:55
  • maybe you want to do a chmod g+s . # files created in directory will be in group G Oct 11, 2014 at 8:56
  • after I did chomd g+s its still the same.
    – James
    Oct 11, 2014 at 9:00

2 Answers 2

2

You will never have execute permission automatically on files because that's a linux security restriction.

The only way I see to have same owner and group recursively for all users is to setup an NFS volume and use all_squash with anonuid and anongid in exports configuration then mount it on the machine.

Without that, you can inherit of the parent group from the top level using setgid bit on the parent directory (chmod g+s new_folder) but not recursively (in subfolders).

For folders permissions, use default acl. Make sure acl is in your mount options with :

tune2fs -l /dev/sdX | grep options

If not add it to /etc/fstab and remount or add it in default mount options with tune2fs -o acl.

Then :

chmod 777 new_folder
setfacl -d -m u::rwx,g::rwx,o::rwx -m m::rwx new_folder
0

There's nothing you can do to the top level folder to control the permissions (other than group) on file and folders created below it.

What you could do if you're in control of the process creating these entries (as others have suggested) is to set umask to 0 (see man page for more details) however this affects all objects created in that session, not just stuff under that folder.

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