I use git to update the working version of the site from the repository on the same server. Folders-files of sites belong to user A, git works through user B.

When I try to update the site files, git swears that there are no rights.

Is it possible to give user B rights centrally for working with site files? Or is it necessary to set rights separately for each site folder?

The structure is as follows:

/var/www/user/data/www/site1.ru /var/www/user/data/www/site2.ru /var/www/user/data/www/siteN.ru 

    2 answers 2

    I'll try to talk about groups and rights. The comment did not fit ...

    No, in * nix the group itself (as well as the user) does not have any rights. Rights are in the file .

    A user and group are assigned to the file. And the user, in turn, is assigned to one or more groups.

    Look at

     avp@avp-xub11:~$ ls -l /var/log/syslog -rw-r----- 1 syslog adm 83972 Mar 19 14:39 /var/log/syslog avp@avp-xub11:~$ 

    These -rw-r ----- are the rights (if briefly and not fully complete - r - read, w - write, x - launch the file for execution) user (in this case, syslog - rw-), group (adm r--) and all others (---) on actions with the file /var/log/syslog .

    Id command

     avp@avp-xub11:~$ id uid=1000(avp) gid=1000(avp) groups=1000(avp),4(adm),20(dialout),24(cdrom),46(plugdev),117(lpadmin),119(admin),124(sambashare),1001(vboxsf) avp@avp-xub11:~$ 

    Shows information about the current user and the groups in which he belongs.

    For example, tail reads the last few lines of a file. If it is started by syslog or avp (it belongs to the adm group), the command will work, and if someone else is not in the adm group (as you can see this is the group assigned to the file. When creating the file, the primary group of the user who creates file, but then you can change it), then we will see /var/log/syslog: Permission denied .

    Here is a brief and all. If you have specific questions - ask.

    • Many thanks! This does not directly answer the question, but the presentation and information content fully contributed to the solution of the problem. Thank! - hcuser

    In general, in nix'ah in such cases it is customary to create a group and add both users to it.

    Actually: https://serverfault.com/questions/26954/how-do-i-share-a-git-repository-with-multiple-users-on-a-machine

    Enough described in detail. There will be questions, write.

    • Thanks, friend, but I understood little. Newbie-s. How can the creation of a group solve a problem if, logically, it is necessary not only to create it, but to give it rights? Can it be easier to somehow run the script on behalf of another user? I'm confused. - hcuser