Preserve file permissions 664 under subdirectories in linux with ACLs

Have you ever wanted to give several users permission to work on files within a directory, but then struggled with what permissions and user:group ownership to set them to so users can always edit the files?

You might think the solution is to make the parent directory owned by a common group, lets say dev, and then try and make the permissions flow through to the files within. This doesn’t work though, and new files will still be created with the user’s umask, typically 644, which is no good as it results in the other users not being able to edit the file.

The solution lies in ACLs (Access Control Lists). Thanks to Pelle at Stackoverflow for making such a concise set of steps to set this up. Blatantly copied here:

First add the acl option to the mounted partition where the directory is you want to apply this to. Add the acl option to the mount point in /etc/fstab:

/dev/xvda1      /               ext3    errors=remount-ro,acl 0       1

Then remount the filesystem to enable it:

# mount -oremount /

Then set the permissions using the setfacl command:

# setfacl -dm u::rwx,g::rwx,o::r /shared/directory

Test by creating a new file in /shared/directory:

/shared/directory$ touch test
/shared/directory$ ls -al test
-rw-rw-r-- 1 jason dev 0 Feb 20 12:37 test

Marvel in the wonders of modern filesystems.


screenshot of FreeCAD showing a cylinder intersecting a cube and the Boolean operation window visible
Cylinder intersecting a cube

Hack A Day has a great article introducing FreeCAD.

FreeCAD is a parametric 3D modeler. Parametric modeling allows you to easily modify your design by going back into your model history and changing its parameters. FreeCAD is open source (LGPL license) and completely modular, allowing for very advanced extension and customization.

There are several great things about this.

  1. It’s free as in beer
  2. It’s free as in libre
  3. It’s available for Windows, Linux and Mac OS X
  4. It’s scriptable in python
  5. you can draw things using constructive solid geometry (CSG)
  6. you can create objects by extruding 2D drawings similarly to Solidworks

If this article is of interest to you, see my other list of OpenSCAD alternatives, and my other posts about free CAD packages.