NAME

chmod - change permissions of files

SYNOPSIS

chmod [-R [-H | -L | -P]] mode file [files ...]

DESCRIPTION

chmod sets the permissions of files. The first argument after the options is permission the files should be given.

OPTIONS

chmod accepts the options described below. The options -L, -H and -P are mutally exclusive, and only the last given option will be honoured. All of -L, -H and -P require the -R option to be set first.

-R

Recurse into directories. Any directories are recursively traversed, and all files and directories will change owner.

-L

Follow symbolic links. By default, chmod will not follow symbolic links. This is a potential dangerous option, as chmod will not check for cycles. Be careful. This option requires the -R option to be set.

-H

Follow symbolic links of command line files/directories only. This option requires the -R option to be set.

-P

Do not follow symbolic links at all. This option requires the -R option to be set.

MODES

Modes are either absolute, or symbolic. An absolute mode is an octal number, calculated by OR-ing the following values:

4000

Suid on execution.

2000

Guid on execution.

1000

The sticky(8) bit is turned on.

0400

Read permission for the ownwer of the file.

0200

Write permission for the ownwer of the file.

0100

Execute permission for the ownwer of the file.

0040

Read permission for those in the group as the group of the file.

0020

Write permission for those in the group as the group of the file.

0010

Execute permission for those in the group as the group of the file.

0004

Read permission for all others.

0002

Write permission for all others.

0001

Execute permission for all others.

Symbolic mode is a comma separated list of actions. Each action has the following format:

      [who] operator [permissions] [operator [permissions] ...]

who consists of zero or more of the following symbols:

u

Permissions for the user (owner) of the file.

g

Permissions for the group of the file.

o

Permissions for all others.

a

Permissions for everyone.

If who is omitted, it will default to a, but the value of your umask is taken into account. chmod will then not set a permission that is masked by your umask.

The operator is one of:

+

Add permissions. If no permissions are given, this action is ignored. If who is absent, set the permission bit as indicated by permissions, but respect the umask settings. If who is given, set the permission bits as indicated by permissions, for those groups indicated by who.

-

Revoke permissions. If no permissions are given, this action is ignored. If who is absent, revoke the permission bit as indicated by permissions, but respect the umask settings. If who is given, revoke the permission bits as indicated by permissions, for those groups indicated by who.

-

Set permissions. The permission bits indicated by who are all cleared. If who isn't given, all permission bits are cleared. Then, if who isn't given, those permission bits in permission whose corresponding bit in the umask is clear are set. Otherwise, the permission bits are set as indicated by who and permission.

permission consists of zero or more of:

r

The read permission bit.

w

The write permission bit.

x

The execute permission bit.

X

The execute permission bit, but only if the target is either a directory, or has at least one execution bit set in the unmodified permission bits. Furthermore, this permission is ignored if operator is either - or =.

s

The suid and guid bit. These will have no effect in combination with the o who setting.

t

The sticky bit. This makes sense only for the others group, however, it will be ignored if o is the only group in the who part of the clause.

u

The original permissions of the user.

g

The original permissions of the group.

o

The original permissions for others.

ENVIRONMENT

The working of chmod is not influenced by any environment variables.

BUGS

It is unlikely there are no bugs. The documentation is at best ambiguous. The OpenBSD documentation does not match the OpenBSD implementation. Furthermore, the implementations of Solaris, SunOS, HP, and GNU all differ from each other, and from OpenBSD.

This manual page needs work. The module PerlPowerTools::SymbolicMode needs to be documented.

chmod parses a symbolic mode once for each file. That is too much redundant work.

chmod can loop forever when symbolic links create cycles.

chmod uses File::Find to recurse.

This manual should have been written in Texinfo, LaTeX, or a funky SGML application. pod2man, pod2html, pod2text and pod2latex are all broken beyond belief.

STANDARDS

It does not make sense to talk about standards in a chmod manual page.

REVISION HISTORY

$Log: chmod,v $
Revision 1.2  2004/08/05 14:17:43  cwest
cleanup, new version number on website

Revision 1.1  2004/07/23 20:10:01  cwest
initial import

Revision 1.3  1999/03/09 02:44:57  abigail
Fixed SybolicMode -> SymbolicMode typo.

Revision 1.2  1999/03/08 03:07:28  abigail
Major documentation tweaks.

Revision 1.1  1999/03/07 12:03:54  abigail
Initial revision

AUTHOR

The Perl implementation of chmod was written by Abigail, perlpowertools@abigail.be.

COPYRIGHT and LICENSE

This program is copyright by Abigail 1999.

This program is free and open software. You may use, copy, modify, distribute, and sell this program (and any modified variants) in any way you wish, provided you do not restrict others from doing the same.