Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

There is one user Lets call him B and he needs access Just to Read the File MEANS READ ACCESS and that file is own by another user A .

How can I grant access to user A's file to User B.

share|improve this question
up vote 5 down vote accepted

Standard UNIX permissions aren't quite that granular. You either need to,

  1. put A and B in the same group[*] and limit the group permissions to read only or
  2. use ACLs

For #1, if this is the only file you care about, create a group called readerb, put user B into it, and change the group ownership on the file (chgrp) to be readerb, and then set the group permissions to be read only (chmod). To be fair, user A doesn't even need to be in the group assuming they still own the file.

To do #2 you need to make sure your distribution supports ACL's, you have the ACL utilities installed, and your filesystems are mounted with ACL support.

With that in place, you would use,

setfacl -m u:B:r thefile.b

to give user B access to thefile.b.

[*] technically user A and B don't need to be in the same group, you could just put user B into the group, or use a group user B is currently the only member of.

share|improve this answer
Lets follow Option 1 bcoz I have no idea about ACL right now. So tell me what will be the affect of putting both users in same group ??? – OmiPenguin Nov 7 '12 at 10:41
If MEANS READ ACCESS is the only file or directory anywhere assigned to that group, then I believe the only affect of putting them in the same group will be that B has the group permissions for that file, rather than the everybody permissions. – dubiousjim Nov 7 '12 at 11:50

you can give 444 permissions to the file that the user wants to access...the command will be chmod 444 /filename/ want to apply recursively and forcely you can try chmod -Rf 444 /filename/.

share|improve this answer

Correct me if I am wrong, but couldn't he also issue a chmod o+r <filename>?

That is, assuming he is the user that owns the file, and wants someone who does not belong to the same groups that he belongs to read the file contents.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.