Search code examples
linuxbashaccess-rights

prevent access to specific directory in my home directory for other user?


I have one directory that I would like to prevent access for specific user. For example /home/myuser/secret should not be readable, accessible etc to specific user. He can see that directoty exists, but can't access / read its contents or modify any way.

How can I do that?


Solution

  • If the filesystem supports ACLs, you can do this:

    setfacl -m "u:dude:---" /home/myuser/secret
    

    Which says the user dude should have no access (neither r nor w nor x) to that directory.

    To verify, run the getfacl command:

    $ getfacl /home/myuser/secret
    # file: home/myuser/secret
    # owner: myuser
    # group: myuser
    user::rwx
    user:dude:---
    group::rwx
    mask::rwx
    other::r-x