251 lines
7.8 KiB
HTML
251 lines
7.8 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of CHMOD</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>CHMOD</H1>
|
|
Section: User Commands (1)<BR>Updated: September 2019<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
chmod - change file mode bits
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<B>chmod</B>
|
|
|
|
[<I>,OPTION/</I>]... <I>,MODE/</I>[<I>,,MODE/</I>]... <I>,FILE/</I>...
|
|
<BR>
|
|
|
|
<B>chmod</B>
|
|
|
|
[<I>,OPTION/</I>]... <I>,OCTAL-MODE FILE/</I>...
|
|
<BR>
|
|
|
|
<B>chmod</B>
|
|
|
|
[<I>,OPTION/</I>]... <I>,--reference=RFILE FILE/</I>...
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
This manual page
|
|
documents the GNU version of
|
|
<B>chmod</B>.
|
|
|
|
<B>chmod</B>
|
|
|
|
changes the file mode bits of each given file according to
|
|
<I>mode</I>,
|
|
|
|
which can be either a symbolic representation of changes to make, or
|
|
an octal number representing the bit pattern for the new mode bits.
|
|
<P>
|
|
|
|
The format of a symbolic mode is [<B>ugoa</B>...][[<B>-+=</B>][<I>perms</I>...]...],
|
|
where
|
|
<I>perms</I>
|
|
|
|
is either zero or more letters from the set
|
|
<B>rwxXst</B>, or a single letter from the set <B>ugo</B>.
|
|
Multiple symbolic
|
|
modes can be given, separated by commas.
|
|
<P>
|
|
|
|
A combination of the letters <B>ugoa</B> controls which users' access
|
|
to the file will be changed: the user who owns it (<B>u</B>), other
|
|
users in the file's group (<B>g</B>), other users not in the file's
|
|
group (<B>o</B>), or all users (<B>a</B>). If none of these are given,
|
|
the effect is as if (<B>a</B>) were
|
|
given, but bits that are set in the umask are not affected.
|
|
<P>
|
|
|
|
The operator <B>+</B> causes the selected file mode bits to be added to
|
|
the existing file mode bits of each file; <B>-</B> causes them to be
|
|
removed; and <B>=</B> causes them to be added and causes unmentioned
|
|
bits to be removed except that a directory's unmentioned set user and
|
|
group ID bits are not affected.
|
|
<P>
|
|
|
|
The letters <B>rwxXst</B> select file mode bits for the affected users:
|
|
read (<B>r</B>), write (<B>w</B>), execute (or search for directories)
|
|
(<B>x</B>), execute/search only if the file is a directory or already
|
|
has execute permission for some user (<B>X</B>), set user or group ID
|
|
on execution (<B>s</B>), restricted deletion flag or sticky bit
|
|
(<B>t</B>). Instead of one or more of these letters, you can specify
|
|
exactly one of the letters <B>ugo</B>: the permissions granted to the
|
|
user who owns the file (<B>u</B>), the permissions granted to other
|
|
users who are members of the file's group (<B>g</B>),
|
|
and the permissions granted to users that are in neither of the two preceding
|
|
categories (<B>o</B>).
|
|
<P>
|
|
|
|
A numeric mode is from one to four octal digits (0-7), derived by
|
|
adding up the bits with values 4, 2, and 1. Omitted digits are
|
|
assumed to be leading zeros.
|
|
The first digit selects the set user ID (4) and set group ID (2) and
|
|
restricted deletion or sticky (1) attributes. The second digit
|
|
selects permissions for the user who owns the file: read (4), write (2),
|
|
and execute (1); the third selects permissions for other users in the
|
|
file's group, with the same values; and the fourth for other users not
|
|
in the file's group, with the same values.
|
|
<P>
|
|
|
|
<B>chmod</B>
|
|
|
|
never changes the permissions of symbolic links; the
|
|
<B>chmod</B>
|
|
|
|
system call cannot change their permissions. This is not a problem
|
|
since the permissions of symbolic links are never used.
|
|
However, for each symbolic link listed on the command line,
|
|
<B>chmod</B>
|
|
|
|
changes the permissions of the pointed-to file.
|
|
In contrast,
|
|
<B>chmod</B>
|
|
|
|
ignores symbolic links encountered during recursive directory
|
|
traversals.
|
|
<A NAME="lbAE"> </A>
|
|
<H2>SETUID AND SETGID BITS</H2>
|
|
|
|
<B>chmod</B>
|
|
|
|
clears the set-group-ID bit of a
|
|
regular file if the file's group ID does not match the user's
|
|
effective group ID or one of the user's supplementary group IDs,
|
|
unless the user has appropriate privileges. Additional restrictions
|
|
may cause the set-user-ID and set-group-ID bits of
|
|
<I>MODE</I>
|
|
|
|
or
|
|
<I>RFILE</I>
|
|
|
|
to be ignored. This behavior depends on the policy and
|
|
functionality of the underlying
|
|
<B>chmod</B>
|
|
|
|
system call. When in
|
|
doubt, check the underlying system behavior.
|
|
<P>
|
|
|
|
For directories
|
|
<B>chmod</B>
|
|
|
|
preserves set-user-ID and set-group-ID bits unless you
|
|
explicitly specify otherwise. You can set or clear the bits with
|
|
symbolic modes like
|
|
<B>u+s</B>
|
|
|
|
and
|
|
<B>g-s</B>.
|
|
|
|
To clear these bits for directories with a numeric mode requires
|
|
an additional leading zero, or leading = like
|
|
<B>00755</B>
|
|
|
|
, or
|
|
<B>=755</B>
|
|
|
|
<A NAME="lbAF"> </A>
|
|
<H2>RESTRICTED DELETION FLAG OR STICKY BIT</H2>
|
|
|
|
The restricted deletion flag or sticky bit is a single bit, whose
|
|
interpretation depends on the file type. For directories, it prevents
|
|
unprivileged users from removing or renaming a file in the directory
|
|
unless they own the file or the directory; this is called the
|
|
<I>restricted deletion flag</I>
|
|
|
|
for the directory, and is commonly found on world-writable directories
|
|
like <B>/tmp</B>. For regular files on some older systems, the bit
|
|
saves the program's text image on the swap device so it will load more
|
|
quickly when run; this is called the
|
|
<I>sticky bit</I>.
|
|
|
|
<A NAME="lbAG"> </A>
|
|
<H2>OPTIONS</H2>
|
|
|
|
<P>
|
|
|
|
Change the mode of each FILE to MODE.
|
|
With <B>--reference</B>, change the mode of each FILE to that of RFILE.
|
|
<DL COMPACT>
|
|
<DT id="1"><B>-c</B>, <B>--changes</B><DD>
|
|
like verbose but report only when a change is made
|
|
<DT id="2"><B>-f</B>, <B>--silent</B>, <B>--quiet</B><DD>
|
|
suppress most error messages
|
|
<DT id="3"><B>-v</B>, <B>--verbose</B><DD>
|
|
output a diagnostic for every file processed
|
|
<DT id="4"><B>--no-preserve-root</B><DD>
|
|
do not treat '/' specially (the default)
|
|
<DT id="5"><B>--preserve-root</B><DD>
|
|
fail to operate recursively on '/'
|
|
<DT id="6"><B>--reference</B>=<I>,RFILE/</I><DD>
|
|
use RFILE's mode instead of MODE values
|
|
<DT id="7"><B>-R</B>, <B>--recursive</B><DD>
|
|
change files and directories recursively
|
|
<DT id="8"><B>--help</B><DD>
|
|
display this help and exit
|
|
<DT id="9"><B>--version</B><DD>
|
|
output version information and exit
|
|
</DL>
|
|
<P>
|
|
|
|
Each MODE is of the form '[ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+'.
|
|
<A NAME="lbAH"> </A>
|
|
<H2>AUTHOR</H2>
|
|
|
|
Written by David MacKenzie and Jim Meyering.
|
|
<A NAME="lbAI"> </A>
|
|
<H2>REPORTING BUGS</H2>
|
|
|
|
GNU coreutils online help: <<A HREF="https://www.gnu.org/software/coreutils/">https://www.gnu.org/software/coreutils/</A>>
|
|
<BR>
|
|
|
|
Report chmod translation bugs to <<A HREF="https://translationproject.org/team/">https://translationproject.org/team/</A>>
|
|
<A NAME="lbAJ"> </A>
|
|
<H2>COPYRIGHT</H2>
|
|
|
|
Copyright © 2018 Free Software Foundation, Inc.
|
|
License GPLv3+: GNU GPL version 3 or later <<A HREF="https://gnu.org/licenses/gpl.html">https://gnu.org/licenses/gpl.html</A>>.
|
|
<BR>
|
|
|
|
This is free software: you are free to change and redistribute it.
|
|
There is NO WARRANTY, to the extent permitted by law.
|
|
<A NAME="lbAK"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<A HREF="/cgi-bin/man/man2html?2+chmod">chmod</A>(2)
|
|
<P>
|
|
|
|
<BR>
|
|
|
|
Full documentation at: <<A HREF="https://www.gnu.org/software/coreutils/chmod">https://www.gnu.org/software/coreutils/chmod</A>>
|
|
<BR>
|
|
|
|
or available locally via: info '(coreutils) chmod invocation'
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="10"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="11"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="12"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="13"><A HREF="#lbAE">SETUID AND SETGID BITS</A><DD>
|
|
<DT id="14"><A HREF="#lbAF">RESTRICTED DELETION FLAG OR STICKY BIT</A><DD>
|
|
<DT id="15"><A HREF="#lbAG">OPTIONS</A><DD>
|
|
<DT id="16"><A HREF="#lbAH">AUTHOR</A><DD>
|
|
<DT id="17"><A HREF="#lbAI">REPORTING BUGS</A><DD>
|
|
<DT id="18"><A HREF="#lbAJ">COPYRIGHT</A><DD>
|
|
<DT id="19"><A HREF="#lbAK">SEE ALSO</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:09 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|