2

I have a Ubuntu 14.04 server with an EXT4 partition. I want to change what permissions new files and folders get when they are created in /home/myuser. I set some options with setfacl, and getfacl /home/myuser returns the following

# file: home/myuser/
# owner: myuser
# group: myuser
# flags: -s-
user::rwx
group::rwx
other::---

Now, in /home/myuser/, I run touch test.txt. getfacl test.txt returns

# file: test.txt
# owner: myuser
# group: myuser
user::rw-
group::rw-
other::r--

If I run mkdir testfolder && getfacl testfolder/, I get

# file: testfolder/
# owner: myuser
# group: myuser
# flags: -s-
user::rwx
group::rwx
other::r-x

I tried setfacl -dm g:myuser:rwx /home/myuser, after which touch test.txt && getfacl test.txt returns

# file: test.txt
# owner: myuser
# group: myuser
user::rw-
group::rwx               #effective:rw-
group:myuser:rwx         #effective:rw-
mask::rw-
other::---

Why? I want all files and folders inside /home/myuser to have 770 mode.

1 Answer 1

2

Add default ACLs, like this:

default:user::rwx
default:group::rwx
default:other::---

Default ACLs are applied on new files and directories under the affected directory.

You can use the following command to accomplish this:

setfacl -dm u::rwx,g::rwx,m::rwx,o::0 /home/myuser
3
  • Now directories have the right permissions. However, files are 660. pastebin.com/xu0E81jf I tested it with /home/myuser/test directory, because I didn't want to mess up my home folder.
    – MikkoP
    Jul 29, 2015 at 18:05
  • I'm not sure why that happens, but I've always seen that as a feature. I think it's better to explicitly enable the execute flag on files than having it set always, just in case.
    – jornane
    Jul 30, 2015 at 6:30
  • Yes, it might be better to enable it on per file basis but it should still work. Running setfacl -m u::rwx,g::rwx,m::rwx,o::0 testfile works as it should.
    – MikkoP
    Jul 30, 2015 at 6:37

You must log in to answer this question.

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