📄 chmod.1
字号:
.\" Copyright (c) 1989, 1990, 1993, 1994.\" The Regents of the University of California. All rights reserved..\".\" This code is derived from software contributed to Berkeley by.\" the Institute of Electrical and Electronics Engineers, Inc..\".\" Redistribution and use in source and binary forms, with or without.\" modification, are permitted provided that the following conditions.\" are met:.\" 1. Redistributions of source code must retain the above copyright.\" notice, this list of conditions and the following disclaimer..\" 2. Redistributions in binary form must reproduce the above copyright.\" notice, this list of conditions and the following disclaimer in the.\" documentation and/or other materials provided with the distribution..\" 3. All advertising materials mentioning features or use of this software.\" must display the following acknowledgement:.\" This product includes software developed by the University of.\" California, Berkeley and its contributors..\" 4. Neither the name of the University nor the names of its contributors.\" may be used to endorse or promote products derived from this software.\" without specific prior written permission..\".\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION).\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF.\" SUCH DAMAGE..\".\" @(#)chmod.1 8.4 (Berkeley) 3/31/94.\".Dd March 31, 1994.Dt CHMOD 1.Os.Sh NAME.Nm chmod.Nd change file modes.Sh SYNOPSIS.Nm chmod.Oo.Fl R.Op Fl H | Fl L | Fl P.Oc.Ar mode.Ar file ....Sh DESCRIPTIONThe.Nm chmodutility modifies the file mode bits of the listed filesas specified by the.Ar modeoperand..PpThe options are as follows:.Bl -tag -width Ds.It Fl HIf the.Fl Roption is specified, symbolic links on the command line are followed.(Symbolic links encountered in the tree traversal are not followed.).It Fl LIf the.Fl Roption is specified, all symbolic links are followed..It Fl PIf the.Fl Roption is specified, no symbolic links are followed..It Fl RChange the modes of the file hierarchies rooted in the filesinstead of just the files themselves..El.PpSymbolic links do not have modes, so unless the.Fl Hor.Fl Loption is set,.Nm chmodon a symbolic link always succeeds and has no effect.The.Fl H ,.Fl Land.Fl Poptions are ignored unless the.Fl Roption is specified.In addition, these options override each other and thecommand's actions are determined by the last one specified..PpOnly the owner of a file or the super-user is permitted to changethe mode of a file..PpThe.Nm chmodutility exits 0 on success, and >0 if an error occurs..Sh MODESModes may be absolute or symbolic.An absolute mode is an octal number constructed by.Ar or-ingthe following values:.Pp.Bl -tag -width 6n -compact -offset indent.It Li 4000set-user-ID-on-execution.It Li 2000set-group-ID-on-execution.It Li 1000sticky bit, see chmod(2).It Li 0400read by owner.It Li 0200write by owner.It Li 0100execute (or search for directories) by owner.It Li 0070read, write, execute/search by group.It Li 0007read, write, execute/search by others.El.PpThe read, write, and execute/search values for group and othersare encoded as described for owner..PpThe symbolic mode is described by the following grammar:.Bd -literal -offset indentmode ::= clause [, clause ...]clause ::= [who ...] [action ...] last_actionaction ::= op [perm ...]last_action ::= op [perm ...]who ::= a | u | g | oop ::= + | \- | =perm ::= r | s | t | w | x | X | u | g | o.Ed.PpThe.Ar whosymbols ``u'', ``g'', and ``o'' specify the user, group, and other partsof the mode bits, respectively.The.Ar whosymbol ``a'' is equivalent to ``ugo''..Pp.ne 1iThe.Ar permsymbols represent the portions of the mode bits as follows:.Pp.Bl -tag -width Ds -compact -offset indent.It rThe read bits..It sThe set-user-ID-on-execution and set-group-ID-on-execution bits..It tThe sticky bit..It wThe write bits..It xThe execute/search bits..It XThe execute/search bits if the file is a directory or any of theexecute/search bits are set in the original (unmodified) mode.Operations with the.Ar permsymbol ``X'' are only meaningful in conjunction with the.Ar opsymbol ``+'', and are ignored in all other cases..It uThe user permission bits in the mode of the original file..It gThe group permission bits in the mode of the original file..It oThe other permission bits in the mode of the original file..El.PpThe.Ar opsymbols represent the operation performed, as follows:.Bl -tag -width 4n.It +If no value is supplied for.Ar perm ,the ``+'' operation has no effect.If no value is supplied for.Ar who ,each permission bit specified in.Ar perm ,for which the corresponding bit in the file mode creation maskis clear, is set.Otherwise, the mode bits represented by the specified.Ar whoand.Ar permvalues are set..It \&\-If no value is supplied for.Ar perm ,the ``\-'' operation has no effect.If no value is supplied for.Ar who ,each permission bit specified in.Ar perm ,for which the corresponding bit in the file mode creation maskis clear, is cleared.Otherwise, the mode bits represented by the specified.Ar whoand.Ar permvalues are cleared..It =The mode bits specified by the.Ar whovalue are cleared, or, if no who value is specified, the owner, groupand other mode bits are cleared.Then, if no value is supplied for.Ar who ,each permission bit specified in.Ar perm ,for which the corresponding bit in the file mode creation maskis clear, is set.Otherwise, the mode bits represented by the specified.Ar whoand.Ar permvalues are set..El.PpEach.Ar clausespecifies one or more operations to be performed on the modebits, and each operation is applied to the mode bits in theorder specified..PpOperations upon the other permissions only (specified by the symbol``o'' by itself), in combination with the.Ar permsymbols ``s'' or ``t'', are ignored..Sh EXAMPLES.Bl -tag -width "u=rwx,go=u-w" -compact.It Li 644make a file readable by anyone and writable by the owner only..Pp.It Li go-wdeny write permission to group and others..Pp.It Li =rw,+Xset the read and write permissions to the usual defaults, butretain any execute permissions that are currently set..Pp.It Li +Xmake a directory or file searchable/executable by everyone if it isalready searchable/executable by anyone..Pp.It Li 755.It Li u=rwx,go=rx.It Li u=rwx,go=u-wmake a file readable/executable by everyone and writable by the owner only..Pp.It Li go=clear all mode bits for group and others..Pp.It Li g=u-wset the group bits equal to the user bits, but clear the group write bit..El.Sh BUGSThere's no.Ar permoption for the naughty bits..Sh SEE ALSO.Xr install 1 ,.Xr chmod 2 ,.Xr stat 2 ,.Xr umask 2 ,.Xr fts 3 ,.Xr setmode 3 ,.Xr symlink 7 ,.Xr chown 8.Sh STANDARDSThe.Nm chmodutility is expected to be POSIX 1003.2compatible with the exception of the.Ar permsymbols.Dq tand.Dq Xwhich are not included in that standard.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -