For context, I’m uploading a csv file to a Postgres database via the psql command line. The cmd can only access the file after I add
Everyone to its permissions and allow full control.
The weird thing is that every time I open the csv and resave it, the permission for
Everyone disappears which means I have to re-add it each time I edit the file. It’s time-consuming and annoying, is there any way to set the permission permanently?
Excel deletes the original file and creates a new one in its place. (This way, if the system crashes, you get to keep either the new file or the old one – you don’t end up with a half-written chunk.)
This results in the new file simply inheriting the default permissions from the parent directory. Although Windows detects this kind of save operation and automatically transfers some attributes from the old file to the new one (through “file system tunnelling”), it doesn’t preserve file permissions.
(In other words, the permissions are not permanent because the file itself is not permanent.)
So you will need to grant inheritable permissions to the parent directory, which will automatically grant them to all files in that directory. (If that is a problem – create a dedicated subdirectory just for the CSV file, and grant permissions on that.)
It’s really unlikely that you actually need to grant permissions to
Everyone. Only the account actually used by Postgres needs read permissions, which could be
NT AUTHORITYNetworkService, or
NT SERVICEPostgreSQL, or something along those lines.