Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

chacl(1)

find(1)

ls(1)

setprivgrp(1M)

chmod(2)

cdf(4)

acl(5)

chmod(1)

NAME

chmod − change file mode

SYNOPSIS

chmod [-A] [-R] mode_list file ...

Obsolescent form:

chmod [-A] [-R] numeric_mode file ...

DESCRIPTION

chmod changes the permissions of any named file according to the symbolic mode_list and/or the absolute numeric_mode.

A symbolic mode_list is a comma-separated list of elements, each of the form:

[who] op [permission] [,...]

interpreted as follows (see EXAMPLES ):

who One or a combination of two or more of the following:

u Modify permissions for user. 

g Modify permissions for group. 

o Modify permissions for others. 

a Modify permissions for all users (a is equivalent to ugo). 

If who is not specified, permission is modified according to the file mode creation mask that chmod inherits (see umask(1)); permission is changed only if the corresponding bit or bits in the creation mask are clear. 

op Must be specifed, and can be one of the following:

+ Add permission to the existing file mode bits. 

- Delete permission from the existing file mode bits. 

= Set permission to specified value (discard existing mode bits). 

permission Any combination of the following letters:

r Add or delete read permission for who.

w Add or delete write permission for who.

x Add or delete execute permission for who.

s Set owner or group ID for who. Useful only if u or g is explicitly or implicitly present in who.

H Hide a directory (change into a context-dependent file).  See cdf(4).

t Set the save-text (sticky) bit.  Useful only if u is explicitly or implicitly present in who.

X Conditionally add or delete execute or search permission as follows:

• If file is a directory, add or delete search permission to the existing file mode for who.

• Same as x if file is a directory, or the current file permissions include execute permission for at least one of user, group, or other. 

• Do nothing if file is not a directory and no execute permissions are set in the current file mode. 

u Copy existing u permissions. 

g Copy existing g permissions. 

o Copy existing o permissions. 

Omitting permission is useful only when used with = to delete all permissions. 

Multiple symbolic modes separated by commas can be given.  Operations are performed in the order specified, and can override preceding operations specified in the same command line. 

Obsolescent Form:

Absolute permissions can be set by specifing a numeric_mode, 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

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 a user having appropriate privileges can set (or retain, if previously set) the sticky bit of a regular file.  In order to set the group ID on execution bit, the group of the file must correspond to your current group ID. 

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

Upon completion, chmod returns one of the following values:

 0 Successful completion. 

>0 Error condition occured. 

EXAMPLES

Deny write permission to others:

chmod o-w file

Make a file executable by everybody:

chmod a+x file

Assign read and execute permission to everybody, and set the set-user-ID bit:

chmod a=rx,u+s file

Assign read and write permission to the file owner, and read permission to everybody else:

chmod u=rw,go=r file

or

chmod 644 file   (obsolescent form)

Traverse a directory subtree making all regular files readable by user and group only, and all executables and directories executable (searchable) by everyone:

chmod -R ug+r,o-r,a+X pathname

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 u-H 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 numeric_mode of 4000 also serves to hide a directory.  For symbolic mode_list elements, 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, POSIX.2

Hewlett-Packard Company  —  HP-UX Release 9.0: August 1992

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026