How can I (programmatically) give write permission on a file to a particular user in Linux? Like, for example, its owner? Everyone has read access to this file.
How can I (programmatically) give write permission on a file to a particular user
Share
In a shell or shell script simply use:
This only modifies the write bit for the user, all other flags remain untouched.
If you want to do it in a C program, you need to use:
First query the existing mode via
… and just set the write bit by doing
newMode = oldMode | S_IWUSR. Seeman 2 chmodandman 2 statfor details.