I have a script that needs to be run with sudo (or as root).
In the script, I create a file with "touch", but since the script is running as root the new file is owned by root.
I know how to change the ownership to a particular user if that user is known, but was wondering if there is a way to create a file that has the same permissions and ownership as the folder that it is in.
In the script, the file is always being created in the user's home folder, so if this is possible it would mean that whichever user ran the script would own the file.
Feathers
In the script, I create a file with "touch", but since the script is running as root the new file is owned by root.
I know how to change the ownership to a particular user if that user is known, but was wondering if there is a way to create a file that has the same permissions and ownership as the folder that it is in.
In the script, the file is always being created in the user's home folder, so if this is possible it would mean that whichever user ran the script would own the file.
Feathers
Comment