Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

as the title, I have to create a file, example:


I created an user and a group, myuser:mygroup and set them to this file.ini

chown myuser:mygroup file.ini

Ok, my problem is

I have another user named mymain this user must read this file, so how can I change the permissions?

IMPORTANT: I ONLY have to allow "mymain" user to read this file, NOT all other users

So myuser (owner of the file) and then mymain. Stop.

share|improve this question

migrated from stackoverflow.com Apr 26 '11 at 9:06

This question came from our site for professional and enthusiast programmers.

Put both users in the same group (and there should be no other user in this group). Assign the the file to the group. Done. –  Felix Apr 26 '11 at 9:02

3 Answers 3

In the traditional Unix file permission system that's not possible: a file has only a single owner. You could create a group containing just the two users that should have access and make that the owning group of the file (and give the desired permissions to that group). This approach has some administrative overhead, however (not every user can create a group and place other users in it).

Many (most) modern filesystems support ACLs, however and they aren't too hard to use. If you want to use POSIX ACLs to give another user read (r) and write (w) permissions then you can use this command:

setfacl -m user:mymain:rw file.ini

Two caveats:

  • The necessary tools aren't always installed. On Ubuntu/Debian they are found in the acl package (sudo apt-get install acl)
  • Even if the filesystem used supports ACLs, it might be that your local filesystem is mounted without support for ACLs. In that case you need to modify the mount parameters to enable it (for ext4, for example, that simply means appending ,acl to the mount options in /etc/fstab).
share|improve this answer

You should make sure that user mymain is a member of mygroup and give the group permissions, like

chmod g+r <filename>

Some filesystems implement ACL (access control lists), and these may proof to be much more useful to you, but they are beyond the scope of my answer here. You will want to read up on ACLs in an enterprise (ADS) setting_


Technically, of course, two users cannot simultaneously be the owner of the same file. Also, if you want to mimic that, you should give full permission to the group, perhaps making a special group for just these two 'owners' and the extent to which this actually mimics owernship will be paltform dependent (old-style UNIX-en tend to be very strict in their rules for allowing chmod/chown)

share|improve this answer

There are two ways you can achieve this.

  1. As noted in @sehe's answer, use the Group facility of Unix permissions.
  2. Create a hard link to the file (so the file exists twice) and make mymain the owner of the hard link - ln myfile mymainfile

I explain more about Unix file permissions here:


share|improve this answer
(Added comment as this site won't allow 1 character edit.) The command should be ln myfile mymainfile to create a hardlink. –  JRT Apr 26 '11 at 9:32
oops - fingers running on autopilot. Edited. –  Majenko Apr 26 '11 at 9:35

Your Answer


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