p The .Dv ISVTX (the .Em sticky bit ) indicates to the system which executable files are shareable (the default) and the system maintains the program text of the files in the swap area. The sticky bit may only be set by the super user on shareable executable files.
p If mode .Dv ISVTX (the `sticky bit') is set on a directory, an unprivileged user may not delete or rename files of other users in that directory. The sticky bit may be set by any user on a directory which the user owns or has appropriate permissions. For more details of the properties of the sticky bit, see .Xr sticky 7 .
p Changing the owner of a file turns off the set-user-id and set-group-id bits; writing to a file turns off the set-user-id and set-group-id bits unless the user is the super-user. This makes the system somewhat more secure by protecting set-user-id (set-group-id) files from remaining set-user-id (set-group-id) if they are modified, at the expense of a degree of compatibility. .Sh RETURN VALUES Upon successful completion, a value of 0 is returned. Otherwise, a value of -1 is returned and .Va errno is set to indicate the error. .Sh ERRORS .Fn chmod and .Fn lchmod will fail and the file mode will be unchanged if: l -tag -width Er t Bq Er ENOTDIR A component of the path prefix is not a directory. t Bq Er ENAMETOOLONG A component of a pathname exceeded .Dv {NAME_MAX} characters, or an entire path name exceeded .Dv {PATH_MAX} characters. t Bq Er ENOENT The named file does not exist. t Bq Er EACCES Search permission is denied for a component of the path prefix. t Bq Er ELOOP Too many symbolic links were encountered in translating the pathname. t Bq Er EPERM The effective user ID does not match the owner of the file and the effective user ID is not the super-user. t Bq Er EPERM The mode includes the setgid bit
q Dv S_ISGID but the file's group is neither the effective group ID nor is it in the group access list. t Bq Er EROFS The named file resides on a read-only file system. t Bq Er EFAULT .Fa path points outside the process's allocated address space. t Bq Er EIO An I/O error occurred while reading from or writing to the file system. t Bq Er EFTYPE The effective user ID is not the super-user, the .Fa mode includes the sticky bit
q Dv S_ISVTX , and .Fa path does not refer to a directory. .El
p .Fn fchmod will fail if: l -tag -width Er t Bq Er EBADF The descriptor is not valid. t Bq Er EINVAL .Fa fd refers to a socket, not to a file. t Bq Er EPERM The effective user ID does not match the owner of the file and the effective user ID is not the super-user. t Bq Er EPERM The mode includes the setgid bit
q Dv S_ISGID but the file's group is neither the effective group ID nor is it in the group access list. t Bq Er EROFS The file resides on a read-only file system. t Bq Er EIO An I/O error occurred while reading from or writing to the file system. t Bq Er EFTYPE The effective user ID is not the super-user, the .Fa mode includes the sticky bit
q Dv S_ISVTX , and .Fa fd does not refer to a directory. .El .Sh SEE ALSO .Xr chmod 1 , .Xr chflags 2 , .Xr chown 2 , .Xr open 2 , .Xr stat 2 , .Xr sticky 7 , .Xr symlink 7 .Sh STANDARDS The .Fn chmod function conforms to .St -p1003.1-90 . .Sh HISTORY The .Fn fchmod function call appeared in x 4.2 . The .Fn lchmod function call appeared in .Nx 1.3 .