I need help understanding how giving write permission to a group, works in Ubuntu. I am logged in as root and have a www-data:www-data
and ftpuser:ftpuser
(user:group
). I add the ftpuser
into the www-data
group using:
usermod -a -G www-data ftpuser
Now my www-data
group has two users.
I then make the group www-data
, owner of the folder /var/www
using:
chgrp -R www-data /var/www
Still i have no write ability to the folder by a group member (though the group owns it) unless i give write permissions to the group. Now according to this best answer i also need to set the permissions to the directory using sudo chmod -R 770 /path/to/the/directory
and this is what confuses me.
If a user is the owner of a directory why can't he write to it?
Can a user of a group give the group write permissions to a folder owned by the group himself?
Where is the group defined in the command sudo chmod -R 770 /path/to/the/directory
? Won't this give recursive permissions to all users?
Best Answer
No, group does not own a file in a sense that the permissions for
owner
apply. Owner permissions apply only to owner - the user; and group permissions apply to the assigned group.He can, except that
ftpuser
in your case is not the owner.Most likely, because you don't say it explicitly:
root
orwww-data
is the owner/var/www
of the file, andftpuser
is a member of the groupwww-data
.Even if the user
www-data
and the groupwww-data
have the same name, they are different entities for the operating system.Again: folder is not owned by a group. If the group has write-permission, any member of the group can change the permissions to the object.
The second
7
refers to the group permissions (7
is a combination ofread
,write
, andexecute
).It will assign (recursively):
read
,write
, andexecute
for the owner (first7
)read
,write
, andexecute
for the group (second7
)0
)