chown

Changes the user and group owner of the specified file or directory.

Library:LibC
Classification:POSIX
Service:File and Directory I/O

Syntax

  #include <sys/stat.h> 
   
  int chown (
     const char   *path,
     uid_t         owner,
     gid_t         group );
  

Parameters

path

(IN) Specifies the file or directory.

owner

(IN) Specifies the ID of the user to make the owner of the file object.

group

(IN) Specifies the ID of the group to make the owner of the file object.

Return Values

If successful, returns 0. Otherwise, returns -1 and sets errno to one of the following:

Decimal

Constant

Description

1

ENOENT

A component of path does not name an existing file or pathname is an empty string.

6

EACCES

Search permission is denied on a component of the path.

65

ENAMETOOLONG

The length of the path parameter exceeds {PATH_MAX}, or a path component is longer than {NAME_MAX}.

69

EPERM

The caller does not have appropriate privileges.

105

ENOCONTEXT

The calling thread has no context.

Remarks

Setting a group owner has no effect on a NetWare file system.

See Also