1CHOWN(2)                      System Calls Manual                     CHOWN(2)
2
3
4

NAME

6       chown - change owner and group of a file
7

SYNOPSIS

9       chown(path, owner, group)
10       char *path;
11       int owner, group;
12
13       fchown(fd, owner, group)
14       int fd, owner, group;
15

DESCRIPTION

17       The  file  that  is named by path or referenced by fd has its owner and
18       group changed as specified.  Only the super-user may change  the  owner
19       of  the file, because if users were able to give files away, they could
20       defeat the file-space accounting procedures.  The owner of the file may
21       change the group to a group of which he is a member.
22
23       On  some systems, chown clears the set-user-id and set-group-id bits on
24       the file to prevent accidental creation of set-user-id and set-group-id
25       programs.
26
27       Fchown  is  particularly  useful when used in conjunction with the file
28       locking primitives (see flock(2)).
29
30       One of the owner or group id's may be left unchanged by  specifying  it
31       as -1.
32
33       If  the  final  component of path is a symbolic link, the ownership and
34       group of the symbolic link is changed, not the ownership and  group  of
35       the file or directory to which it points.
36

RETURN VALUE

38       Zero  is returned if the operation was successful; -1 is returned if an
39       error occurs, with a more specific  error  code  being  placed  in  the
40       global variable errno.
41

ERRORS

43       Chown will fail and the file will be unchanged if:
44
45       [ENOTDIR]      A component of the path prefix is not a directory.
46
47       [EINVAL]       The  pathname  contains  a character with the high-order
48                      bit set.
49
50       [ENAMETOOLONG] A component of a pathname exceeded 255 characters, or an
51                      entire path name exceeded 1023 characters.
52
53       [ENOENT]       The named file does not exist.
54
55       [EACCES]       Search  permission is denied for a component of the path
56                      prefix.
57
58       [ELOOP]        Too many symbolic links were encountered in  translating
59                      the pathname.
60
61       [EPERM]        The effective user ID is not the super-user.
62
63       [EROFS]        The named file resides on a read-only file system.
64
65       [EFAULT]       Path  points  outside  the  process's  allocated address
66                      space.
67
68       [EIO]          An I/O error occurred while reading from or  writing  to
69                      the file system.
70
71       Fchown will fail if:
72
73       [EBADF]        Fd does not refer to a valid descriptor.
74
75       [EINVAL]       Fd refers to a socket, not a file.
76
77       [EPERM]        The effective user ID is not the super-user.
78
79       [EROFS]        The named file resides on a read-only file system.
80
81       [EIO]          An  I/O  error occurred while reading from or writing to
82                      the file system.
83

SEE ALSO

85       chown(8), chgrp(1), chmod(2), flock(2)
86
87
88
894th Berkeley Distribution        May 22, 1986                         CHOWN(2)
Impressum