Adding a user as an owner of some directory

10,387

Solution 1

Do you mean that you want two users to have the same permissions for all of the contents of a directory?

If so, there are potentially two ways:

  • Add the two users to a group, and give that group suitable access to the directory. You can create a fresh group just for this, if you want.

  • Use ACLs. This depends on your unix: the BSDs tend now to have good support for ACLs, Linuxes somewhat less so (broadly speaking). Do man acl to see what's available. This route can get confusing quite quickly.

The other possibility is to set the directory's sticky bit (see man sticky). This is how the /tmp directory is configured, and it lets multiple users create and own files within a directory, without letting them see others' files. I don't know if that matches what you're looking for, but if it does, it's more straightforward than either of the two suggestions above.

Solution 2

A file or directory has: 1) and owner (git in your case); 2) a group (staff in you case) and 3) others. In your case the owner as 'rw' permission, the group has 'r' permission, and others have 'r' permission.

If you want everybody to have the same permissions, say 'rw', then use:

chmod g+w,o+w myfile

If you want only another user to have the same permissions as the owner, then you must put that other user into the staff group. Or, create another group, and put all the other users in that group. Creating a group and adding members to that group depends on your OS. Once you have the group you would do:

   chgrp mygrp myfile
   chmod g+w myfile
Share:
10,387
user1611830
Author by

user1611830

Updated on June 15, 2022

Comments

  • user1611830
    user1611830 almost 2 years

    Sorry, if my question is too simple. I know how to change owner for a directory 'my directory'. But suppose I have a git user that owns a file 'myfile' inside directory

    -rw-r--r--   1 git   staff 9201 somedate myfile
    

    But I want to add an existing user that has the same level of ownerships of all the file's directory. How can I do that ?