How to have files created by root automatically have permissions for other users?

  • I'm logging in via SSH as root, and then using a script to sync a directory with a cloud storage service. The trouble is, all the files created by the script then belong to the root user.


    When I then try over SMB to manage these files, I'm told I don't have sufficient permissions. I then execute chmod -R 777 on that folder and that fixes the problem, but this is a hassle to do every time.


    Is there a way to designate the folder as belonging to a certain user or to always have certain default permissions so that new files have those permissions as well?

  • 1) why not login or run the script as the user? Running scripts/services as root is often discouraged, where possible.


    2) set the g+s bit on the folder and/or default ACL so that it always inherits the group, combine with ACLs and/or umask to give the desired group permissions.


    3) have the script set the appropriate permissions or ownership of files it creates

    • Offizieller Beitrag

    Instead of chmod, use chgrp to change the group of all the files to the group users. Every user created from the OMV web interface is a member of the users group and will be able to access them.


    chgrp -R users <foldername>

    omv 7.0.5-1 sandworm | 64 bit | 6.8 proxmox kernel

    plugins :: omvextrasorg 7.0 | kvm 7.0.13 | compose 7.1.4 | k8s 7.1.0-3 | cputemp 7.0.1 | mergerfs 7.0.4


    omv-extras.org plugins source code and issue tracker - github - changelogs


    Please try ctrl-shift-R and read this before posting a question.

    Please put your OMV system details in your signature.
    Please don't PM for support... Too many PMs!

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!