chmod(1)
NAME
chmod − change file mode
SYNOPSIS
chmod [−R] mode file ...
DESCRIPTION
chmod changes the permissions of any named file according to mode which can be absolute or symbolic. An absolute mode is an octal number constructed from the logical OR of the following mode bits:
Miscellaneous mode bits:
______________ 4000 set user ID on execution (file)
| or hide directory (see cdf(4))
| ________ 2000 set group ID on execution
| | __ 1000 sticky bit; see chmod(2)
| | |
s s t
Permission mode bits:
__________________ 0400 read by owner
| ________________ 0200 write by owner
| | ______________ 0100 execute (search in directory) by owner
| | | ____________ 0040 read by group
| | | | __________ 0020 write by group
| | | | | ________ 0010 execute/search by group
| | | | | | ______ 0004 read by others
| | | | | | | ____ 0002 write by others
| | | | | | | | __ 0001 execute/search by others
| | | | | | | | |
r w x r w x r w x
A symbolic mode has the form:
[ who ] op permission [ op permission ]
The who part is a combination of the letters u (for user’s permissions), g (group) and o (other). The letter a stands for ugo, the default if who is omitted.
op can be + to add permission to the file’s mode, − to take away permission, or = to assign permission absolutely (all other bits are reset).
permission is any combination of the letters r (read), w (write), x (execute), s (set owner or group ID), H (hide directory), and t (save text or sticky); u, g or o indicate that permission is to be taken from the current mode. Omitting permission is only useful with = to take away all permissions.
Multiple symbolic modes separated by commas can be given. Operations are performed in the order specified. The letter s is only useful with u or g and t only works with u.
Options
−A Preserve any optional access control list (ACL) entries associated with the file. (By default, in conformance with the IEEE Standard POSIX 1003.1-1988, optional ACL entries are deleted.) For information about access control lists, see acl(5).
−R Recursively change the file mode bits. For each file operand that names a directory, chmod alters the file mode bits of the named directory and all files and subdirectories in the file hierarchy below it.
Only the owner of a file (or the user with the appropriate privileges) can change its mode. Only the with the appropriate privileges can set the sticky bit. In order to set the group ID, the group of the file must correspond to your current group ID. A given user’s or group’s ability to use this command to set the user ID or group ID can be restricted by setprivgrp(1M).
When using chmod on a symbolic link, the mode of the file referred to by the link is changed.
EXTERNAL INFLUENCES
International Code Set Support
Single- and multi-byte character code sets are supported.
RETURN VALUE
Exit values are:
0 Successful completion.
>0 Error condition occured.
EXAMPLES
Deny write permission to others:
chmod o−w file
Make a file executable:
chmod +x file
Assign read and execute permission to everybody, and set the set-user-ID bit:
chmod 4555 file
Assign read and write permission to the file owner, and read permission to everybody else:
chmod 644 file
Change permissions on all regular files in a directory subtree to mode 444, and permissions on all directories to 555:
find pathname −type f −print │ xargs chmod 444
find pathname −type d −print │ xargs chmod 555
Piping output from find to xargs(1) is more efficient than the find −exec primary (see find(1)).
Note that an inadvertent change of the miscellaneous mode bits of a directory to 4000 or greater, or use of the permission letter H (hide directory), "hides" a directory (turning it into a context dependent file). Such a directory will quite probably not have your context and therefore will be hidden from you.
If a file seems to be missing from a directory, use ls −H to determine the cause. Recovery is accomplished by the addition of a "+" to the dirname:
chmod 777 dirname+
WARNINGS
Access Control Lists
Access control list descriptions in this entry apply only to standard HP-UX operating systems. If HP-UX BLS software has been installed, access control lists are handled differently. Refer to HP-UX BLS documentation for information about access control lists in the HP-UX BLS environment.
DEPENDENCIES
NFS The −A option is not supported for networked files.
HP Clustered Environment
The absolute mode of 4000 also serves to hide a directory. For symbolic mode, the permission letter H is used to hide a directory (see cdf(4)). Root directories cannot be made hidden.
AUTHOR
chmod was developed by AT&T and HP.
SEE ALSO
chacl(1), find(1), ls(1), setprivgrp(1M), chmod(2), cdf(4), acl(5).
STANDARDS CONFORMANCE
chmod: SVID2, XPG2, XPG3, proposed POSIX.2 FIPS (June 1990)
Hewlett-Packard Company — HP-UX Release 8.05: June 1991