automaticaly assign ownership of folder to new file: how ??

Chris Green cl at isbd.net
Fri Nov 4 10:08:54 UTC 2022


On Fri, Nov 04, 2022 at 09:38:30AM +0100, robert rottermann wrote:
> Hi there
> 
> i am using Ubuntu 20.04.
> 
> Is there a way, that when creating a file in a folder, that it automatically 
> inherits the ownership of the folder.
> And not the one of the user creating the file?
> 
It's quite well buried in the documentation but if you set the
'sticky' bit (I think it's that one) in the permissions of a directory
then you get what you want.

Yes, I've just tried it:-

    chris$ mkdir test
    chris$ sudo -s
    [sudo] password for chris: 
    root at t470# ls -al test
    total 8
    drwxrwxr-x  2 chris chris 4096 Nov  4 10:05 .
    drwxr-xr-x 21 chris chris 4096 Nov  4 10:05 ..
    root at t470# chmod 2755 test
    root at t470# ls -la test
    total 8
    drwxr-sr-x  2 chris chris 4096 Nov  4 10:05 .
    drwxr-xr-x 21 chris chris 4096 Nov  4 10:05 ..
    root at t470# chgrp isbd test
    root at t470# ls -al test
    total 8
    drwxr-sr-x  2 chris isbd  4096 Nov  4 10:05 .
    drwxr-xr-x 21 chris chris 4096 Nov  4 10:05 ..
    root at t470# exit
    exit
    chris$ cd test
    /home/chris/tmp/test
    chris$ ls -al
    total 8
    drwxr-sr-x  2 chris isbd  4096 Nov  4 10:05 .
    drwxr-xr-x 21 chris chris 4096 Nov  4 10:05 ..
    chris$ touch fred
    chris$ ls -al
    total 8
    drwxr-sr-x  2 chris isbd  4096 Nov  4 10:06 .
    drwxr-xr-x 21 chris chris 4096 Nov  4 10:05 ..
    -rw-rw-r--  1 chris isbd     0 Nov  4 10:06 fred
    chris$ 


-- 
Chris Green



More information about the ubuntu-users mailing list