chmod更改文件的权限

 1 #include "apue.h"
 2 
 3 
 4 int main(int argc,char *argv[])
 5 {
 6     struct stat stabuf;
 7 
 8     if(stat("zbzhuang",&stabuf) < 0)
 9         err_sys("stat error for foo");
10     if(chmod("zbzhuang",(stabuf.st_mode & ~S_IXGRP)|S_ISGID) < 0)
11         err_sys("chmod error for foo");
12 
13     if(chmod("caylin",S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH) < 0)
14         err_sys("chmod error for bar");
15 
16     return 0;
17 }

原文地址:https://www.cnblogs.com/zzb-Dream-90Time/p/6963643.html