Give a group write permission to a folder

13,994

though the group owns it

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.

If a user is the owner of a directory why can't he write to it?

He can, except that ftpuser in your case is not the owner.

Most likely, because you don't say it explicitly: root or www-data is the owner /var/www of the file, and ftpuser is a member of the group www-data.

Even if the user www-data and the group www-data have the same name, they are different entities for the operating system.

Can a user of a group give the group write permissions to a folder owned by the group himself?

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.

Where is the group defined in the command sudo chmod -R 770 /path/to/the/directory

The second 7 refers to the group permissions (7 is a combination of read, write, and execute).

Won't this give recursive permissions to all users?

It will assign (recursively):

  • read, write, and execute for the owner (first 7)
  • read, write, and execute for the group (second 7)
  • no permissions for other users (last 0)
Share:
13,994

Related videos on Youtube

PaulB
Author by

PaulB

Updated on September 18, 2022

Comments

  • PaulB
    PaulB over 1 year

    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?

  • Scott - Слава Україні
    Scott - Слава Україні over 5 years
    Why are you including s in chmod -R g+ws?  Did you mean chmod -R g+wx?