14

In linux, how can I give access permissions to a file/folder to a specific person. In other words suppose I want to allow only and only user fred to be able to read a file, then how do I do that?

Note that I know about chmod and all, but Linux doesn't seem to provide a fine tuned access permission control where you can specify the access control of one specific user.

Thanks, Alison

Johan
  • 74,508
  • 24
  • 191
  • 319
Alison Lee
  • 270
  • 1
  • 4
  • 9
  • Make fred the owner and `chmod 0600` (or `0700` if it's executable) – Jim Garrison Feb 20 '12 at 02:57
  • 5
    But I don't want to give that user the ownership of the file. I only want that user to be able to read it, that's all. I mean such granularity in access control is so essential; how can Linux not provide such an access control? – Alison Lee Feb 20 '12 at 03:00
  • That granularity is not available in plain Linux. I believe SELinux will give you that ability, but I haven't used it. I recommend you delete this post and post your question on [linux.se] – Jim Garrison Feb 20 '12 at 03:03
  • 1
    I agree that this question is probably better suited for Super User or Unix and Linux. However, briefly, the simplest way to do what you want is likely to use Unix groups. If you want to grant read-only access to user `bob`, but don't want to make `bob` the file owner, do `chgrp bob MY_FILE; chmod g=r MY_FILE`. – gsteff Feb 20 '12 at 03:09
  • 1
    This belongs to superuser (and the answer is likely to include POSIX ACLs). – n. m. could be an AI Feb 20 '12 at 03:16

1 Answers1

28

Unix uses discretionary access control (DAC) for permissions and access control. For better security SELinux provide mandatory access control (MAC). This is consider difficult for administrators to set up and maintain.

Use commands:

chown user_name file
chown user_name folder
chown -R user_name folder #recursive
Daniel
  • 465
  • 4
  • 5