• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 322
  • Last Modified:

Folder Permissions in Linux

I'm setting up an sftp and want one folder where people can add and remove files.

I want the group "sftp" to have read and write access to /home/sftp (this is not a home folder, just located there).

How can I do this so that any new files as well (uploaded by either user) can be rw to both users?
1 Solution
The group sftp needs to own this directory. That can be achieved by running:

chgrp sftp /home/sftp

And now you need to tell the filesystem that all files created in this directory will inherit its permissions from the directory itself. Therefore you need to set the setgid bit for that directory (therefore, all files will be created with the group set to sftp):

chmod 2775 /home/sftp

Now you need to set the umask for these two users to 002 instead of the default 022, that way all new files created will have rw-rw-r-- permissions (owner and group writable) and all new directories will have rwxrwxr-x.

If your users are members of the group 'sftp' and it's the 'sftp' group that is putting the files in that folder then setting the group for that folder to 'sftp' like so (in a terminal):

chgrp -R sftp /home/sftp

Then give the group read and write access like so:

chmod g+r /home/sftp
chmod g+w /home/sftp

I hope that helps.

jjmartineziiiAuthor Commented:

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now