-
Notifications
You must be signed in to change notification settings - Fork 54
chown
果冻虾仁 edited this page Apr 19, 2020
·
5 revisions
#include <unistd.h>
int chown(const char *path, uid_t owner, gid_t group);
int fchown(int fd, uid_t owner, gid_t group);
int lchown(const char *path, uid_t owner, gid_t group);实际执行需要root权限。也就是使用root身份或者sudo来运行该程序的可执行文件。
If the owner or group is specified as -1, then that ID is not changed.
- lchown修改符号链接时,修改的是符号链接权限。
- chown修改符号链接时,修改符号链接指向的文件的权限。
- fchown修改符号连接时,行为和chown相同。只不过它的参数是文件的描述符。
0 成功; -1 失败
Talk is cheap, show me the code!
C语言API包含部分标准C的API、POSIX标准的系统编程API(一些Linux独有的系统API会单独注明)。
大部分头文件源码在/usr/include目录下。
因为涉及到大量的POSIX编程。所以最好下载POSIX函数的man手册。
apt-get install manpages-posix
apt-get install manpages-posix-dev
默认安装了manpages-dev,所以不装POSIX的man手册是可以查看绝大部分API的。
但是不装的话,有些API是不能看到的,比如posix_spawn函数。
yum install man-pages.noarch
关于目录
左侧的目录并非以函数为索引依据,主要是以系统的man手册页面为索引依据。
比如exec里面包含6个函数、pipe里面包含pipe()和pipe2()两个函数,但是它们都是属于一个man页面中。