1

I want all new files created in one folder to have an owner called user1

How can I do that?

sysadmin1138
  • 133,124
  • 18
  • 176
  • 300

4 Answers4

1

In FreeBSD exist suiddir(http://www.freebsd.org/cgi/man.cgi?query=mount&sektion=8). You may mount partitions with suiddir option and add 4000 permissions.

In linux GFS2 support suiddir. Also you may use cron or inotify, to change file owner.

bindbn
  • 5,211
  • 2
  • 26
  • 24
  • And what about dir not being a mountpoint? – drAlberT Oct 15 '10 at 10:08
  • sorry but i diddnt get how can i use it –  Oct 15 '10 at 10:47
  • bindbn's answer is correct but terse. There is no easy way to implement what you want on Linux - the setuid bit does not act like the setgid bit any of the standard filesystems. FreeBSD (and Linux using only the GFS2 filesystem) support a suiddir mount option that makes the setuid bit act like the setgid bit on directories. – akramer Feb 22 '11 at 03:21
0

You can have "all files belong to a group", by chmod g+s dir

If this doesn`t fit your needs, you have to deal with ACL and a default mask.

ThorstenS
  • 3,122
  • 19
  • 21
0

Hai Linux always associates a file or directory with a user and a group. For example, assume I have a file named webmaster.txt in my home directory. If I run the command ls -l webmaster.txt, I get the following result: -rw-rw-r- 1 root root 1024 Feb 21 15:10 example.txt

Here I think your directory is /root/test file is example.txt user is user1 & group is user1

If you want to change permission, gust follow the instruction

chown -R user1.user1 /root/test/

Best wishes

Premjith
  • 82
  • 1
  • 2
  • 11
0

Although all the documentation seems to say otherwise, the sticky bit seems to do it to an extent.

e.g. to preserve the parent directory group.

chmod g+s [directory name]

Now any files or directories created within this directory inherit the parent group.

Not sure if this will be enough. Usually it's the owner/group of the current user or process that sets these.

hookenz
  • 14,472
  • 23
  • 88
  • 143