Go to the previous, next section.

chown and fchown

SYNOPSIS

int chown(const char *path, uid_t owner, gid_t group);

int fchown(int fd, uid_t owner, gid_t group);

PARAMETERS

path: [in] points to the path of the file to modify.

fd: [in] the file descriptor to modify.

owner: [in] the new uid. -1 for no change.

group: [in] the new gid. -1 for no change.

DESCRIPTION

chown changes the uid and gid of file specified by path to owner and group. fchown changes the uid and gid of file descriptor fd to owner and group. The superuser may do whatever he wishes with the uid and gid of a file. The owner of a file may only change the gid of the file to any group he belongs to.

RETURN VALUE

On success zero is returned. On error, -1 is returned and errno is set to one of the following values:

for chown:

for fchown:

Go to the previous, next section.