Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

How can I do that?

share|improve this question

4 Answers 4

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.

share|improve this answer
    
And what about dir not being a mountpoint? –  AlberT Oct 15 '10 at 10:08
    
sorry but i diddnt get how can i use it –  John 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 3:21

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.

share|improve this answer

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

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

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