Andrius
Andrius

Reputation: 21168

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?

Upvotes: 0

Views: 474

Answers (3)

Mark Plotnick
Mark Plotnick

Reputation: 10271

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

Upvotes: 1

DonCallisto
DonCallisto

Reputation: 29942

If you want to let other user navigate an arbitrary /home/ dir of another user, but you want to deny others to do that, you can procede as follows

  • let group to read and execute on that folder chmod 750 /home/myuser/secret
  • create a group that will be assigned to that folder groupadd secret_users
  • chown -R :secret_users /home/myuser/secret
  • add users to the group by editing /etc/group file. user inserted here could read files inside that folder but other users can't

Upvotes: 0

Fabio Hyneck
Fabio Hyneck

Reputation: 46

Hello Linux Permissions are set as "Whitelist". You try to specify a blacklist.

I'w create a group with all user who should have access.

Upvotes: 0

Related Questions