Changes the file protection of a file.
#include <stat.h> int chmod (const char *file_spec, mode_t mode);
| Value | Privilege |
|---|---|
| 0400 | OWNER:READ |
| 0200 | OWNER:WRITE |
| 0100 | OWNER:EXECUTE |
| 0040 | GROUP:READ |
| 0020 | GROUP:WRITE |
| 0010 | GROUP:EXECUTE |
| 0004 | WORLD:READ |
| 0002 | WORLD:WRITE |
| 0001 | WORLD:EXECUTE |
When you supply a mode value of 0, the chmod function gives the file the user's default file protection.
The system is given the same privileges as the owner. A WRITE privilege also implies a DELETE privilege.
| 0 | Indicates that the mode is successfully changed. |
| -1 | Indicates that the change attempt has failed. |