Linux chmod、fchmod函数
chmod、fchmod
头文件
函数原型
int fchmod(int fd, mode_t mode);
功能
参数
S_ISUID (04000) set-user-ID (set process effective user ID onexecve(2))//执行时设置用户IDS_ISGID (02000) set-group-ID (set process effective group ID onexecve(2); mandatory locking, as described infcntl(2); take a new file's group from parent direc-tory, as described in chown(2) and mkdir(2))//执行时设置组IDS_ISVTX (01000) sticky bit (restricted deletion flag, as describedin unlink(2))//保存正文(粘住位)S_IRUSR (00400) read by owner//用户(所有者)读S_IWUSR (00200) write by owner//用户(所有者)写S_IXUSR (00100) execute/search by owner ("search" applies for direc-tories, and means that entries within the directorycan be accessed)//用户(所有者)执行S_IRGRP (00040) read by group//组读S_IWGRP (00020) write by group//组写S_IXGRP (00010) execute/search by group//组执行S_IROTH (00004) read by others//其他读S_IWOTH (00002) write by others//其他写S_IXOTH (00001) execute/search by others//其他执行S_IRWXU (UNIX) //用户读写执行S_IRWXG (UNIX) //组读写执行S_IRWXO (UNIX) //其他读写执行
unix环境高级编程的例子
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>int main(int argc, char * argv[])
{struct stat statbuf;if(stat("foo", &statbuf) < 0){printf("stat error for foo\n");} if(chmod("foo", (statbuf.st_mode & ~S_IXGRP) | S_ISGID) < 0){printf("chmod error for foo\n");}if(chmod("bar", S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) < 0){printf("chmod error for bar\n");}exit(0);
}
Linux chmod、fchmod函数相关推荐
- linux chmod和fchmod设置 文件和目录权限设置
这两个函数使我们可以更改现有文件的访问权限: #include <sys/stat.h> int chmod( const char *pathname, mode_t mode ); i ...
- linux文件操作函数程序,linux 文件操作函数
文件操作(Linux) 常用linux函数库中的基本函数 1. close函数,关闭文件 2. creat函数,建立文件 3. dup.dup2函数,复制文件描述词 4. fcntl函数,文件描述词操 ...
- Linux 常用C函数说明-文件权限控制篇
chdir(改变当前的工作(目录) 相关函数 getcwd,chroot 表头文件 #include<unistd.h> 定义函数 int chdir(const char * pa ...
- linux常用c函数(中文版)
都是linux的c函数东西略多,用页面搜索来查找吧. << Back to man.ChinaUnix.net isalnum(测试字符是否为英文或数字) 相关函数 isalpha,isd ...
- unix环境高级编程-4.9-chmod,fchmod函数和粘住位
这两个函数可以更改我们现有文件的访问权限. #include <sys/stat.h>int chmod(const char *pathname,mode_t mode);int fch ...
- Linux下select函数实现的聊天服务器
转载: http://blog.csdn.net/microtong/article/details/4989902 Linux下select函数实现的聊天服务器 佟强 http://blog.cs ...
- 嵌入式linux通过程序设置系统时间,嵌入式新手如何设定Linux的时间函数
一.时间相关说明 格林威治时间表示0时区的标准时间.其他时区的时间和此标准时间均有时间差.UTC(UniversalTime Coordinated)是世界协调时间,是格林威治时间在互联网中的表示方法 ...
- Linux chmod命令修改文件与文件夹权限命令代码
在Linux中要修改一个文件夹或文件的权限我们需要用到linux chmod命令来做,下面我写了几个简单的实例大家可参考一下. 语法如下: chmod [who] [+ | - | =] [mode] ...
- linux c数字转字符串函数,Linux常用C函数—字符串转换篇
Linux 常用C 函数-字符串转换篇 atof (将字符串转换成浮点型数) 相关函数 atoi ,atol ,strtod ,strtol ,strtoul 定义函数 double atof(con ...
- linux下syscall函数,SYS_gettid,SYS_tgkill
出处:http://blog.chinaunix.net/uid-28458801-id-4630215.html linux下syscall函数,SYS_gettid,SYS_tgkill 2014 ...
最新文章
- Docker入门六部曲——容器
- Microsoft Hyper-V Server 2012开启虚拟化-虚拟机管理
- linux系统中文件编程,Linux当中的文件系统
- echarts图形报表缓存问题(option数据缓存)
- 《大道至简》第六章读后感
- Java opengl openal_项目里用到了openal,特分享一下openal全教程
- iptables 防火墙的基本使用
- php excel下载打不开了,php下载excel无法打开的解决方法
- adcetris研发历程_AZ、MSD、吉利德争相布局ADC药物
- 野火IMJAVA开发的即时通讯系统源码
- uva11054 - Wine trading in Gergovia(等价转换,贪心法)
- Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2问题解决
- Python爬取图片时,urllib提示没有属性urlretrieve的问题
- java中的值传递与引用传递
- visio防火墙可以连接什么_分享一款网工必备网络拓扑图绘制工具Visio以及大量厂商图标库...
- JS设计模式 - 工厂模式
- *jqwidgets jqxgrid 使用心得 jqxgrid教程 jqxgrid+SpringMVC(初级) 集成JAVA SSM
- 我敲,原来滚动监听可以酱紫写
- 工欲善其事,必先利其器 - 修炼Android Studio操作技巧
- 一款Img图床模板码 扩展性超强纯Html+响应式