UNIX - How to give user rights over another user and so I don't need to sudo or type password?
Solution 1:
As requested, a bit of a tutorial on groups. Hopefully this isn't too elementary.
By default, most user accounts are also part of a group of the same name. To determine what groups an account is a member of, use the groups command.
# groups root
root : root bin daemon sys adm disk wheel
The first one listed is the primary group, and will be the default group owner of any files that user creates. That's listed in the output of ls as the second 'root' entry.
# touch testfile
# ls -l testfile
-rw-r--r-- 1 root root 19 Jan 29 08:37 testfile
In order to add a user to a group, you use usermod as shown. The lowercase "-g" flag you gave it changes the primary group. It may be better to change just a secondary one, using the "-G" and "-a" flag. Namely, to put the git user into luddico's group.
# usermod -G luddico -a git
# groups git
git : git luddico
This should give git access to any files that are owned by the luddico group, and have appropriate group permissions. Group permissions are the second "rwx" set listed in ls. The testfile I showed above only allows read access by the root group. If you wanted to give all members of that group write access, you would have to use chmod for that.
# ls -l testfile
-rw-r--r-- 1 root root 19 Jan 29 08:37 testfile
# chmod g+w testfile
# ls -l testfile
-rw-rw-r-- 1 root root 19 Jan 29 08:37 testfile
Now anyone in the root group can read or write to testfile. Apply the same concept to Luddico's files.
Solution 2:
If you want to grant a user (such as git in your examples) access to another user's space, put them in the same group and set group rights accordingly.
If you need more complex access control list functionality, you should look into POSIX ACLs as provided by getfacl(1) and setfacl(1).