I have a folder which permission is set to 777 but when I add any files or folder unziping in that folder. Extracted files or folder permission never change. Destination folder permission is 777 and I want what I will add in that folder will automatically get permission of 777.

When I add any files or folder by extracting .zip in that folder, extracted folder/files permission won't change automatically. I always have to chmod for newly add file/folder!

  • What is the umask set to un the account which is extracting the files? – Hennes May 13 '14 at 17:35
  • @Hennes, thanks to mention about umask, I didn't know much about that. After your comments, I have searched google and learnt more about it. By that, I have solved my problem partially though. – Ibrahim May 13 '14 at 18:38

What you want is called ACL - Access Control Lists.

Access Control List (ACL) provides an additional, more flexible permission mechanism for file systems. It is designed to assist with UNIX file permissions. ACL allows you to give permissions for any user or group to any disc resource.

acl package should be already installed, to check it run: dpkg -s acl.

To use ACL's you should enable it for your filesystem. But it can be already enabled. To check it use tune2fs -l. Substitute /dev/sda6 for your system:

$ tune2fs -l /dev/sda6 | grep "Default mount options:"
Default mount options:    user_xattr acl

If you see acl word - it is already enabled for device /dev/sda6.

If you don't see acl word - run tune2fs -o acl /dev/sda6 to enable it.

To modify ACL use setfacl command. To add permissions use setfacl -m.

To set permission for user:

$ setfacl -m "u:username:rwx" /path/to/folder

This will set rwx ACL, for user username to /path/to/folder. This means that all files created in this folder will have rwx permission for username.

To set permission for group:

$ setfacl -m "g:groupname:rwx" /path/to/folder

This will set rwx ACL, for group groupname to /path/to/folder. This means that all files created in this folder will have rwx permission for group groupname.

To set permission for other:

$ setfacl -m "o:rwx" /path/to/folder

This will set rwx ACL, for other to /path/to/folder. This means that all files created in this folder will have rwx permission for other.

To check permission:

$ getfacl /path/to/folder

To combine acl

$ setfacl -m u:username:rwx,g:groupname:rwx,o:rwx /path/to/folder

Default ACL

 The new object inherits the default ACL of the containing directory as its
 access ACL.

 If no default ACL is associated with a directory, the mode parameter to the func‐
 tions creating file objects and the file creation mask (see umask(2)) are used to
 determine the ACL of the new object:

 The new object is assigned an access ACL containing entries of tag types
 ACL_USER_OBJ, ACL_GROUP_OBJ, and ACL_OTHER. The permissions of these entries
 are set to the permissions specified by the file creation mask.

So if you set default ACL, it would be preferred ACL. That means if set ACL for user or group, new created file would inherit default acl anyway. Be carefully with default ACL.

To set default acl use -d key,

$ setfacl -d -m u::rwx,g::rwx,o::rwx /path/to/folder

or use default word

$ setfacl -m default:u::rwx,default:g::rwx,default:o::rwx /path/to/folder

Be carefully with setting default ACL. For example if set like this:

$ setfacl -d -m o:--x /path/to/folder

and now fetch this ACL

$ getfacl /path/to/folder
# file: path/to/folder
# owner: c0rp
# group: c0rp

default ACL for group and user will be rwx automatically!

Remove ACL

$ setfacl -b /path/to/folder

This will remove all ACL's from folder


If you are only user in system, I recommend use default ACL.

$ setfacl -d -m u::rwx,g::rwx,o::rwx /path/to/folder

This will do what you want for /path/to/folder


archlinux - https://wiki.archlinux.org/index.php/Access_Control_Lists

help.ubuntu - https://help.ubuntu.com/community/FilePermissionsACLs

  • Well this is awesome and complete answer! Thank you @c0rp – Ibrahim May 13 '14 at 18:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.