23

There's a specific user that I don't want to be able to access my home directory. How do I deny access to them, while still allowing access to others who would normally have it?

29

If you want to limit access to users outside of your group or any other user, the question is a duplicate of Restrict access to my home folder from another standard user account

Otherwise, if you want to restrict access to just one user, call it enemyuser, use ACL:

cd ~
setfacl -m u:enemyuser:000 .

...and just enemyuser will have the access to your home directory denied.

To check the effect:

[romano@pern:~] % chacl -l .
. [u::rwx,u:enemyuser:---,g::r-x,m::r-x,o::r-x] 

To remove the ACL, you just say:

setfacl -x u:enemyuser .

The *acl commands used here are from the package acl, which should be installed by default (at least, I think).

  • Thanks a lot. Exacly what I wanted. In case I change my mind and I need to allow enemyuser access, what do I need to do? – Rob John Apr 14 '15 at 15:53
  • 3
    To remove the ACL, replace the -m with -x. – Riking Apr 14 '15 at 19:06
  • On my system, the command lsacl does not exist. Where did you get it? – Paddy Landau Apr 21 '15 at 11:25
  • @PaddyLandau oops, it's a script I got from internet some time ago that pretty-prints long ACL lists. I changed the answer using standard tools. Here: lists.gnu.org/archive/html/coreutils/2014-10/msg00031.html – Rmano Apr 21 '15 at 12:40

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.