Ubuntu – How to prevent one user in particular from accessing the home directory

permissions

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?

Best Answer

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).

Related Question