Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am working with a group on a supercomputer and we are storing all project files in my home directory, the problem is if I need to manage some of the files, I can't because they own the files. I need a way for all of the files placed inside the directory in my home folder to be owned by me. The other people are uploading the files using SFTP

share|improve this question

migrated from Jul 23 '12 at 5:41

This question came from our site for professional and enthusiast programmers.

Would group ownership be good enough? – Jon Lin Jun 27 '12 at 17:24
We're all in the same group. The problem is I want everyone to be able to write to this directory and all files inside it, so when someone puts a file in the directory is is -rwxrwx--- so everyone can overwrite the files with the newest version when they have a newer versiom – DontTurnAround Jun 27 '12 at 18:19
Which Unix specifically? – dave4420 Jun 27 '12 at 22:30

As root, run chown username:group -R * and replace your name and group.

Now of course they might not be able to edit them now, so add them to your group and give it group-editable permissions. (chmod xyz -R *) and replace "xyz" with the appropriate permissions.

share|improve this answer

You can change the owner with chown but it is not a good solution, because you must do this always.

I would solve your task using SGID bit for a directory.

You can set this bit to the directory where users upload files and then these files will have your group as a group owner.

$ mkdir -p ~/incoming/
$ chmod o+wt ~/incoming/   # making the directory world writeable; setting sticky bit to avoid deletion of files
$ chmod g+s ~/incoming/    # setting setgid for the directory

And don't forget to set umask 002 for the ftp/sftp server.

For SFTP-server you can do this in sshd_config. Rewrite the line with sftp-server in this way:

Subsystem sftp /usr/lib/openssh/sftp-server -u 022
share|improve this answer
This didn't work – DontTurnAround Jun 27 '12 at 18:18
What do you mean "didn't work"? Whicg group is the group owner of files in the incoming directory? – Igor Chubin Jun 27 '12 at 19:14

If it's just a matter of you needing to be able to edit the files in a certain directory, where other people have ownership of the files, you can create a group and add some modes to this directory. (Replacing folder with the path of your home directory):

  1. Create a group (if you don't already have an existing one) that you and all the other people you are working with belong to. See the groupadd command. And then add everyone to that group using usermod. You can verify who's in this group by looking at /etc/group file.

  2. Change the folder's default mask so that group are read/write.

    setfacl -d -m g::rwx folder
  3. Create a setgid so that when new files are placed in this directory, they belong to the group:

    chmod g+ws folder
  4. Now set the group and the ownerships:

    chown -R youruser:thegroupname folder
    chmod -R g+w folder

If you really want to force all files to be owned by you, you need to make it so the mechanism that they place these files change the ownership to you, if it is either ftp or samba etc. Otherwise you can use a file watcher like lsyncd to watch the folder and change the ownership when new files appear.

share|improve this answer
This didn't work – DontTurnAround Jun 27 '12 at 18:18
@user1036238 is the filesystem that folder is on mounted with the acl option? (You should be able to see the mount options in /etc/fstab) – Jon Lin Jul 13 '12 at 21:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.