ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzahz_5.4.0.1/chmod.htm

350 lines
8.8 KiB
HTML
Raw Normal View History

2024-04-02 14:02:31 +00:00
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org">
<meta http-equiv="Content-Type" content=
"text/html; charset=utf-8">
<title>chmod - Change file modes</title>
<LINK rel="stylesheet" type="text/css" href="../rzahg/ic.css">
</HEAD>
<body bgcolor="#FFFFFF">
<!-- Java sync-link -->
<SCRIPT LANGUAGE="Javascript" SRC="../rzahg/synch.js" TYPE="text/javascript"></SCRIPT>
<h2>chmod - Change file modes</h2>
<strong>Synopsis</strong>
<p><strong>chmod [ -R [-H | -L | -P] ] [ -h ]</strong> <em>mode
file ...</em></p>
<p><strong>Description</strong></p>
<p>The <strong>chmod</strong> utility modifies the file mode bits
of <em>file</em> as specified by the <em>mode</em> operand.</p>
<p>To change the mode of a file, you must have one of the following
authorities:</p>
<ul>
<li>The current user has *ALLOBJ special authority.</li>
<li>The current user is the owner of the file.</li>
</ul>
<p>By default, <strong>chmod</strong> follows symbolic links and
changes the mode on the file pointed to by the symbolic link.
Symbolic links do not have modes so using <strong>chmod</strong> on
a symbolic link always succeeds and has no effect.</p>
<p>The <strong>-H</strong>, <strong>-L</strong> and <strong>
-P</strong> options are ignored unless the <strong>-R</strong>
option is specified. In addition, these options override each other
and the command's actions are determined by the last one
specified.</p>
<p>
Note that <strong>chmod</strong> changes the i5/OS<SUP>(TM)</SUP> data authorities for
an object. Use the <a href="../cl/chgaut.htm">CHGAUT</a> CL command
to change the i5/OS<SUP>(TM)</SUP> object authorities for an object.
</p>
<p><strong>Options</strong></p>
<dl>
<dt><strong>-H</strong></dt>
<dd>If the <strong>-R</strong> option is specified, symbolic links
on the command line are followed. Symbolic links encountered in the
tree traversal are not followed. Since symbolic links do not have modes
<strong>chmod</strong> has no effect on the symbolic links.</dd>
<dt><strong>-L</strong></dt>
<dd>If the <strong>-R</strong> option is specified, both symbolic
links on the command line and symbolic links encountered in the
tree traversal are followed.</dd>
<dt><strong>-P</strong></dt>
<dd>If the <strong>-R</strong> option is specified, no symbolic
links are followed. Since symbolic links do not have modes
<strong>chmod</strong> has no effect on the symbolic links.</dd>
<dt><strong>-R</strong></dt>
<dd>If <em>file</em> designates a directory, <strong>chmod</strong>
changes the mode of each file in the entire subtree connected at
that point.</dd>
<dt><strong>-h</strong></dt>
<dd>Do not follow symbolic links. Since symbolic links do not have modes
<strong>chmod</strong> has no effect on the symbolic links.</dd>
</dl>
<p><strong>Operands</strong></p>
<p>A <em>mode</em> may be absolute or symbolic. An absolute mode is
a three or four digit octal number constructed by or-ing the
following values:</p>
<dl>
<dt><strong>4000</strong></dt>
<dd>Set-user-id on execute bit</dd>
<dt><strong>2000</strong></dt>
<dd>Set-group-id on execute bit</dd>
<dt><strong>1000</strong></dt>
<dd>Restricted deletion bit for a directory</dd>
<dt><strong>0400</strong></dt>
<dd>Allow read by owner</dd>
<dt><strong>0200</strong></dt>
<dd>Allow write by owner</dd>
<dt><strong>0100</strong></dt>
<dd>Allow execute/search by owner</dd>
<dt><strong>0040</strong></dt>
<dd>Allow read by group</dd>
<dt><strong>0020</strong></dt>
<dd>Allow write by group</dd>
<dt><strong>0010</strong></dt>
<dd>Allow execute/search by group</dd>
<dt><strong>0004</strong></dt>
<dd>Allow read by other</dd>
<dt><strong>0002</strong></dt>
<dd>Allow write by other</dd>
<dt><strong>0001</strong></dt>
<dd>Allow execute/search by other</dd>
</dl>
<p>A symbolic mode is described by the following grammar:</p>
<ul>
<li><em>mode</em> ::= clause [, clause ...]</li>
<li><em>clause</em> ::= [who ...] [action ...] last_action</li>
<li><em>action</em> ::= op [perm ...]</li>
<li><em>last_action</em> ::= op [perm ...]</li>
<li><em>who</em> ::= a | u | g | o</li>
<li><em>op</em> ::= + | - | =</li>
<li><em>perm</em> ::= r | w | x | X | s | t | u | g | o</li>
</ul>
<p>The <em>who</em> symbols specify who is granted or denied the
permissions as follows:</p>
<dl>
<dt><strong>u</strong></dt>
<dd>The owner permission bits.</dd>
<dt><strong>g</strong></dt>
<dd>The group permission bits.</dd>
<dt><strong>o</strong></dt>
<dd>The other permission bits.</dd>
<dt><strong>a</strong></dt>
<dd>The owner, group, and other permission bits. It is equivalent
to specifying the <strong>ugo</strong> symbols together.</dd>
</dl>
<p>The <em>op</em> symbols represent the operation performed, as
follows:</p>
<dl>
<dt><strong>+</strong></dt>
<dd>Grant the specified permission. If no value is supplied for
<em>perm</em>, the "+" operation has no effect. If no value is
supplied for <em>who</em>, each permission bit specified in <em>
perm</em>, for which the corresponding bit in the file mode
creation mask is clear, is set. Otherwise, the mode bits
represented by the specified <em>who</em> and <em>perm</em> values
are set.</dd>
<dt><strong>-</strong></dt>
<dd>Deny the specified permission. If no value is supplied for <em>
perm</em>, the "-" operation has no effect. If no value is supplied
for <em>who</em>, each permission bit specified in <em>perm</em>,
for which the corresponding bit in the file mode creation mask is
clear, is cleared. Otherwise, the mode bits represented by the
specified <em>who</em> and <em>perm</em> values are cleared.</dd>
<dt><strong>=</strong></dt>
<dd>Clear the selected permission field and set it to the specified
permission. The mode bits specified by the <em>who</em> value are
cleared, or, if no <em>who</em> value is specified, the owner,
group and other mode bits are cleared. Then, if no value is
supplied for <em>who</em>, each permission bit specified in <em>
perm</em>, for which the corresponding bit in the file mode
creation mask is clear, is set. Otherwise, the mode bits
represented by the specified <em>who</em> and <em>perm</em> values
are set.</dd>
</dl>
<p>The <em>perm</em> symbols represent the portions of the mode
bits as follows:</p>
<dl>
<dt><strong>r</strong></dt>
<dd>The read bits.</dd>
<dt><strong>w</strong></dt>
<dd>The write bits.</dd>
<dt><strong>x</strong></dt>
<dd>The execute/search bits.</dd>
<dt><strong>X</strong></dt>
<dd>The execute/search bits if the file is a directory or if any of
the execute/search bits are set in the original (unmodified) mode.
Operations with this symbol are only meaningful in conjunction with
the <em>op</em> symbol &quot;+&quot;, and are ignored in all other
cases.</dd>
<dt><strong>s</strong></dt>
<dd>The set-user-id on execute bit when the owner permission bits
are set or the set-group-id on execute bit when the group
permission bits are set.</dd>
<dt><strong>t</strong></dt>
<dd>The restricted deletion bit when the object is a directory.
It can be used when the <em>who</em> symbol is <strong>a</strong> or there is no
<em>who</em> symbol. It is ignored if the file is not a directory or the <em>who</em>
symbol is <strong>u</strong>, <strong>g</strong>, or <strong>o</strong>.
</dd>
</dl>
<p>Each <em>clause</em> specifies one or more operations to be
performed on the mode bits, and each operation is applied to the
mode bits in the order specified.</p>
<p><strong>Exit Status</strong></p>
<ul>
<li>0 on success</li>
<li>&gt;0 if an error occurs</li>
</ul>
<p><strong>Related information</strong></p>
<ul>
<li><a href="chgrp.htm">chgrp - Change file group
permission</a></li>
<li><a href="chown.htm">chown - Change file ownership</a></li>
</ul>
<strong>Examples</strong>
<ol>
<li>Grant read and write permission to owner and read permission to group and other
using an absolute mode.
<pre>
chmod 644 myfile
</pre>
</li>
<li>Deny write permission to group and other.
<pre>
chmod go-w myfile
</pre>
</li>
<li>Clear all permissions that are currently set and grant read and write permissions
to owner, group, and other.
<pre>
chmod =rw myfile
</pre>
</li>
<li>Grant search permission on a directory to owner, group, and other if search
permission is set for one them.
<pre>
chmod +X mydir
</pre>
</li>
<li>Grant read, write, and execute permission to owner and read and execute permission
to group and other using an absolute mode.
<pre>
chmod 755 myfile
</pre>
</li>
<li>Clear all permissions for group and other.
<pre>
chmod go= myfile
</pre>
</li>
<li>Set the group permissions equal to the owner permission, but deny
write permission to the group.
<pre>
chmod g=u-w myfile
</pre>
</li>
<li>Set the set-user-id on execute bit and grant read, write, and execute permission
to the owner and execute permission for other using an absolute mode.
<pre>
chmod 4701 myfile
</pre>
</li>
</ol>
<!-- end ibmbody========================================================= -->
</body>
</html>