下面几个chown函数可用于更改文件的用户ID和组ID。

#include <unistd.h>

int chown(const char *pathname, uid_t owner, gid_t group);
int fchown(int fd, uid owner, gid_t group);
int fchownat(int fd, const char *pathname, uid_t owner, gid_t group, int flag);
int lchown(const char *pathname, uid_t owner, git_t group);

基于BSD的系统一直规定只有超级用户才能改改一个文件的所有者。这样做的原因是防止用户改变其文件的所有者从而摆脱磁盘空间限额对他们的限制。SystemV则允许任一用户更改他们所拥有文件的所有者。

results matching ""

    No results matching ""