SUNWcsu
chmod changes or assigns the mode of a file. The mode of a file specifies its permissions and other attributes. The mode may be absolute or symbolic.
An absolute mode is specified using octal numbers:
chmod nnnn file ...
where:
- n
- a number from 0 to 7. An absolute mode is constructed from the OR of any of the following modes:
- Set user ID on execution.
- 20#0
- Set group ID on execution if # is 7, 5, 3, or 1.
- Enable mandatory locking if
- # is 6, 4, 2, or 0.
- For directories, files are created with BSD semantics for propagation
- of the group ID. With this option, files and subdirectories created in the directory inherit the group ID of the directory, rather than of the current process. It may be cleared only by using symbolic mode.
- Turn on sticky bit. See chmod(2) .
- Allow read by owner.
- Allow write by owner.
- Allow execute (search in directory) by owner.
- Allow read, write, and execute (search) by owner.
- Allow read by group.
- Allow write by group.
- Allow execute (search in directory) by group.
- Allow read, write, and execute (search) by group.
- Allow read by others.
- Allow write by others.
- Allow execute (search in directory) by others.
- Allow read, write, and execute (search) by others.
Note that the setgid bit cannot be set (or cleared) in absolute mode;
it must be set (or cleared) in symbolic mode using g+s (or g-s).
A symbolic mode specification has the following format:
chmod <symbolic-mode-list> file...
where: <symbolic-mode-list> is a comma-separated list (with no intervening whitespace) of symbolic mode expressions of the form:
[who] operator [permissions]
Operations are performed in the order given. Multiple permissions letters following a single operator cause the corresponding operations to be performed simultaneously.
- who
- zero or more of the characters u, g, o, and a specifying whose permissions are to be changed or assigned:
- u
- user’s permissions
- g
- group’s permissions
- o
- others’ permissions
- a
- all permissions (user, group, and other)
- +
- Add permissions.
- If
- permissions is omitted, nothing is added.
- If
- who is omitted, add the file mode bits represented by permissions, except for the those with corresponding bits in the file mode creation mask.
- If
- who is present, add the file mode bits represented by the permissions.
- -
- Take away permissions.
- If
- permissions is omitted, do nothing.
- If
- who is omitted, clear the file mode bits represented by permissions, except for those with corresponding bits in the file mode creation mask.
- If
- who is present, clear the file mode bits represented by permissions.
- =
- Assign permissions absolutely.
- If
- who is omitted, clear all file mode bits; if who is present, clear the file mode bits represented by who.
- If
- permissions is omitted, do nothing else.
- If
- who is omitted, add the file mode bits represented by permissions, except for the those with corresponding bits in the file mode creation mask.
- If
- who is present, add the file mode bits represented by permissions.
User Group Other rwx rwx rwx
The letter s is only meaningful
with u or g, and t only works with u.
chmod g+x,+l filechmod g+s,+l file
Deny execute permission to everyone:
example% chmod a-x file
Allow only read permission to everyone:
example% chmod 444 file
Make a file readable and writable by the group and others:
example% chmod go+rw fileexample% chmod 066 file
Cause a file to be locked during access:
example% chmod +l file
Allow everyone to read, write, and execute the file and turn on the set group-ID.
example% chmod a=rwx,g+s fileexample% chmod 2777 file
Absolute changes don’t work for the set-group-ID bit of a directory. You must use g+s or g-s.
chmod permits you to produce useless modes so long as they are not illegal (for instance, making a text file executable). chmod does not check the file type to see if mandatory locking is meaningful.
If the filesystem is mounted with the nosuid option, setuid execution is not allowed.