19ddb49cbSWarner Losh.\"- 24b88c807SRodney W. Grimes.\" Copyright (c) 1989, 1990, 1993, 1994 34b88c807SRodney W. Grimes.\" The Regents of the University of California. All rights reserved. 44b88c807SRodney W. Grimes.\" 54b88c807SRodney W. Grimes.\" This code is derived from software contributed to Berkeley by 64b88c807SRodney W. Grimes.\" the Institute of Electrical and Electronics Engineers, Inc. 74b88c807SRodney W. Grimes.\" 84b88c807SRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without 94b88c807SRodney W. Grimes.\" modification, are permitted provided that the following conditions 104b88c807SRodney W. Grimes.\" are met: 114b88c807SRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright 124b88c807SRodney W. Grimes.\" notice, this list of conditions and the following disclaimer. 134b88c807SRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright 144b88c807SRodney W. Grimes.\" notice, this list of conditions and the following disclaimer in the 154b88c807SRodney W. Grimes.\" documentation and/or other materials provided with the distribution. 16fbbd9655SWarner Losh.\" 3. Neither the name of the University nor the names of its contributors 174b88c807SRodney W. Grimes.\" may be used to endorse or promote products derived from this software 184b88c807SRodney W. Grimes.\" without specific prior written permission. 194b88c807SRodney W. Grimes.\" 204b88c807SRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 214b88c807SRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 224b88c807SRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 234b88c807SRodney W. Grimes.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 244b88c807SRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 254b88c807SRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 264b88c807SRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 274b88c807SRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 284b88c807SRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 294b88c807SRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 304b88c807SRodney W. Grimes.\" SUCH DAMAGE. 314b88c807SRodney W. Grimes.\" 32a758566cSConrad Meyer.Dd January 7, 2017 334b88c807SRodney W. Grimes.Dt CHMOD 1 344b88c807SRodney W. Grimes.Os 354b88c807SRodney W. Grimes.Sh NAME 364b88c807SRodney W. Grimes.Nm chmod 374b88c807SRodney W. Grimes.Nd change file modes 384b88c807SRodney W. Grimes.Sh SYNOPSIS 39be8b1497SRuslan Ermilov.Nm 40abb1dad1SRuslan Ermilov.Op Fl fhv 41abb1dad1SRuslan Ermilov.Op Fl R Op Fl H | L | P 424b88c807SRodney W. Grimes.Ar mode 4347dec781SRuslan Ermilov.Ar 444b88c807SRodney W. Grimes.Sh DESCRIPTION 454b88c807SRodney W. GrimesThe 46cbf6f7d3SPhilippe Charnier.Nm 474b88c807SRodney W. Grimesutility modifies the file mode bits of the listed files 484b88c807SRodney W. Grimesas specified by the 494b88c807SRodney W. Grimes.Ar mode 504b88c807SRodney W. Grimesoperand. 514b88c807SRodney W. Grimes.Pp 524b88c807SRodney W. GrimesThe options are as follows: 532267d53bSRuslan Ermilov.Bl -tag -width indent 542267d53bSRuslan Ermilov.It Fl f 552267d53bSRuslan ErmilovDo not display a diagnostic message if 562267d53bSRuslan Ermilov.Nm 572267d53bSRuslan Ermilovcould not modify the mode for 582267d53bSRuslan Ermilov.Va file , 592267d53bSRuslan Ermilovnor modify the exit status to reflect such failures. 604b88c807SRodney W. Grimes.It Fl H 614b88c807SRodney W. GrimesIf the 624b88c807SRodney W. Grimes.Fl R 63ad34caceSSteven Hartlandoption is specified, symbolic links on the command line are followed 64ad34caceSSteven Hartlandand hence unaffected by the command. 65ad34caceSSteven Hartland(Symbolic links encountered during tree traversal are not followed.) 662267d53bSRuslan Ermilov.It Fl h 672267d53bSRuslan ErmilovIf the file is a symbolic link, change the mode of the link itself 682267d53bSRuslan Ermilovrather than the file that the link points to. 694b88c807SRodney W. Grimes.It Fl L 704b88c807SRodney W. GrimesIf the 714b88c807SRodney W. Grimes.Fl R 724b88c807SRodney W. Grimesoption is specified, all symbolic links are followed. 734b88c807SRodney W. Grimes.It Fl P 744b88c807SRodney W. GrimesIf the 754b88c807SRodney W. Grimes.Fl R 764b88c807SRodney W. Grimesoption is specified, no symbolic links are followed. 7795a09b05SRuslan ErmilovThis is the default. 784b88c807SRodney W. Grimes.It Fl R 79ad34caceSSteven HartlandChange the modes of the file hierarchies rooted in the files, 804b88c807SRodney W. Grimesinstead of just the files themselves. 81ad34caceSSteven HartlandBeware of unintentionally matching the 82ad34caceSSteven Hartland.Dq Pa ".." 83ad34caceSSteven Hartlandhard link to the parent directory when using wildcards like 84ad34caceSSteven Hartland.Dq Li ".*" . 855bb83b98SDavid E. O'Brien.It Fl v 865bb83b98SDavid E. O'BrienCause 875bb83b98SDavid E. O'Brien.Nm 88154f47ddSRuslan Ermilovto be verbose, showing filenames as the mode is modified. 89154f47ddSRuslan ErmilovIf the 9030d90946SDavid E. O'Brien.Fl v 9130d90946SDavid E. O'Brienflag is specified more than once, the old and new modes of the file 9230d90946SDavid E. O'Brienwill also be printed, in both octal and symbolic notation. 934b88c807SRodney W. Grimes.El 944b88c807SRodney W. Grimes.Pp 954b88c807SRodney W. GrimesThe 964b88c807SRodney W. Grimes.Fl H , 974b88c807SRodney W. Grimes.Fl L 984b88c807SRodney W. Grimesand 994b88c807SRodney W. Grimes.Fl P 1004b88c807SRodney W. Grimesoptions are ignored unless the 1014b88c807SRodney W. Grimes.Fl R 1024b88c807SRodney W. Grimesoption is specified. 1034b88c807SRodney W. GrimesIn addition, these options override each other and the 1044b88c807SRodney W. Grimescommand's actions are determined by the last one specified. 1054b88c807SRodney W. Grimes.Pp 106a758566cSConrad MeyerIf 107a758566cSConrad Meyer.Nm 108a758566cSConrad Meyerreceives a 109a758566cSConrad Meyer.Dv SIGINFO 110a758566cSConrad Meyersignal (see the 111a758566cSConrad Meyer.Cm status 112a758566cSConrad Meyerargument for 113a758566cSConrad Meyer.Xr stty 1 ) , 114a758566cSConrad Meyerthen the current filename as well as the old and new modes are displayed. 115a758566cSConrad Meyer.Pp 1164b88c807SRodney W. GrimesOnly the owner of a file or the super-user is permitted to change 1174b88c807SRodney W. Grimesthe mode of a file. 1186fca4c7cSRuslan Ermilov.Sh EXIT STATUS 119d628d776SRuslan Ermilov.Ex -std 1204b88c807SRodney W. Grimes.Sh MODES 1214b88c807SRodney W. GrimesModes may be absolute or symbolic. 122d5440753SJoseph KoshyAn absolute mode is an octal number constructed from the sum of 123d5440753SJoseph Koshyone or more of the following values: 1244b88c807SRodney W. Grimes.Pp 1254b88c807SRodney W. Grimes.Bl -tag -width 6n -compact -offset indent 1264b88c807SRodney W. Grimes.It Li 4000 1272267d53bSRuslan Ermilov(the setuid bit). 1282267d53bSRuslan ErmilovExecutable files with this bit set 129d5440753SJoseph Koshywill run with effective uid set to the uid of the file owner. 1302267d53bSRuslan ErmilovDirectories with this bit set will force all files and 131d5440753SJoseph Koshysub-directories created in them to be owned by the directory owner 132d5440753SJoseph Koshyand not by the uid of the creating process, if the underlying file 133d5440753SJoseph Koshysystem supports this feature: see 13452bf64c7SJulian Elischer.Xr chmod 2 135d5440753SJoseph Koshyand the 1362267d53bSRuslan Ermilov.Cm suiddir 137d5440753SJoseph Koshyoption to 138cc056fafSChris Costello.Xr mount 8 . 1394b88c807SRodney W. Grimes.It Li 2000 1402267d53bSRuslan Ermilov(the setgid bit). 1412267d53bSRuslan ErmilovExecutable files with this bit set 142d5440753SJoseph Koshywill run with effective gid set to the gid of the file owner. 1434b88c807SRodney W. Grimes.It Li 1000 1442267d53bSRuslan Ermilov(the sticky bit). 145b11b570dSGiorgos KeramidasSee 146b11b570dSGiorgos Keramidas.Xr chmod 2 147b11b570dSGiorgos Keramidasand 148e2ea39cbSSergey Kandaurov.Xr sticky 7 . 1494b88c807SRodney W. Grimes.It Li 0400 150d5440753SJoseph KoshyAllow read by owner. 1514b88c807SRodney W. Grimes.It Li 0200 152d5440753SJoseph KoshyAllow write by owner. 1534b88c807SRodney W. Grimes.It Li 0100 154154f47ddSRuslan ErmilovFor files, allow execution by owner. 155154f47ddSRuslan ErmilovFor directories, allow the owner to 156d5440753SJoseph Koshysearch in the directory. 157d5440753SJoseph Koshy.It Li 0040 158d5440753SJoseph KoshyAllow read by group members. 159d5440753SJoseph Koshy.It Li 0020 160d5440753SJoseph KoshyAllow write by group members. 161d5440753SJoseph Koshy.It Li 0010 162154f47ddSRuslan ErmilovFor files, allow execution by group members. 163154f47ddSRuslan ErmilovFor directories, allow 164d5440753SJoseph Koshygroup members to search in the directory. 165d5440753SJoseph Koshy.It Li 0004 166d5440753SJoseph KoshyAllow read by others. 167d5440753SJoseph Koshy.It Li 0002 168d5440753SJoseph KoshyAllow write by others. 169d5440753SJoseph Koshy.It Li 0001 170154f47ddSRuslan ErmilovFor files, allow execution by others. 171154f47ddSRuslan ErmilovFor directories allow others to 172d5440753SJoseph Koshysearch in the directory. 1734b88c807SRodney W. Grimes.El 1744b88c807SRodney W. Grimes.Pp 175d5440753SJoseph KoshyFor example, the absolute mode that permits read, write and execute by 176d5440753SJoseph Koshythe owner, read and execute by group members, read and execute by 1770237755dSTom Rhodesothers, and no set-uid or set-gid behaviour is 755 178d5440753SJoseph Koshy(400+200+100+040+010+004+001). 1794b88c807SRodney W. Grimes.Pp 1804b88c807SRodney W. GrimesThe symbolic mode is described by the following grammar: 1814b88c807SRodney W. Grimes.Bd -literal -offset indent 1824b88c807SRodney W. Grimesmode ::= clause [, clause ...] 183aa387b2dSBill Swingleclause ::= [who ...] [action ...] action 1844b88c807SRodney W. Grimesaction ::= op [perm ...] 1854b88c807SRodney W. Grimeswho ::= a | u | g | o 1864b88c807SRodney W. Grimesop ::= + | \- | = 1874b88c807SRodney W. Grimesperm ::= r | s | t | w | x | X | u | g | o 1884b88c807SRodney W. Grimes.Ed 1894b88c807SRodney W. Grimes.Pp 1904b88c807SRodney W. GrimesThe 1914b88c807SRodney W. Grimes.Ar who 1924b88c807SRodney W. Grimessymbols ``u'', ``g'', and ``o'' specify the user, group, and other parts 1934b88c807SRodney W. Grimesof the mode bits, respectively. 1944b88c807SRodney W. GrimesThe 1954b88c807SRodney W. Grimes.Ar who 1964b88c807SRodney W. Grimessymbol ``a'' is equivalent to ``ugo''. 1974b88c807SRodney W. Grimes.Pp 1984b88c807SRodney W. GrimesThe 1994b88c807SRodney W. Grimes.Ar perm 2004b88c807SRodney W. Grimessymbols represent the portions of the mode bits as follows: 2014b88c807SRodney W. Grimes.Pp 2024b88c807SRodney W. Grimes.Bl -tag -width Ds -compact -offset indent 2034b88c807SRodney W. Grimes.It r 2044b88c807SRodney W. GrimesThe read bits. 2054b88c807SRodney W. Grimes.It s 2064b88c807SRodney W. GrimesThe set-user-ID-on-execution and set-group-ID-on-execution bits. 2074b88c807SRodney W. Grimes.It t 2084b88c807SRodney W. GrimesThe sticky bit. 2094b88c807SRodney W. Grimes.It w 2104b88c807SRodney W. GrimesThe write bits. 2114b88c807SRodney W. Grimes.It x 2124b88c807SRodney W. GrimesThe execute/search bits. 2134b88c807SRodney W. Grimes.It X 2144b88c807SRodney W. GrimesThe execute/search bits if the file is a directory or any of the 2154b88c807SRodney W. Grimesexecute/search bits are set in the original (unmodified) mode. 2164b88c807SRodney W. GrimesOperations with the 2174b88c807SRodney W. Grimes.Ar perm 2184b88c807SRodney W. Grimessymbol ``X'' are only meaningful in conjunction with the 2194b88c807SRodney W. Grimes.Ar op 2204b88c807SRodney W. Grimessymbol ``+'', and are ignored in all other cases. 2214b88c807SRodney W. Grimes.It u 22263b46af9SSheldon HearnThe user permission bits in the original mode of the file. 2234b88c807SRodney W. Grimes.It g 22463b46af9SSheldon HearnThe group permission bits in the original mode of the file. 2254b88c807SRodney W. Grimes.It o 22663b46af9SSheldon HearnThe other permission bits in the original mode of the file. 2274b88c807SRodney W. Grimes.El 2284b88c807SRodney W. Grimes.Pp 2294b88c807SRodney W. GrimesThe 2304b88c807SRodney W. Grimes.Ar op 2314b88c807SRodney W. Grimessymbols represent the operation performed, as follows: 2324b88c807SRodney W. Grimes.Bl -tag -width 4n 2334b88c807SRodney W. Grimes.It + 2344b88c807SRodney W. GrimesIf no value is supplied for 2354b88c807SRodney W. Grimes.Ar perm , 2364b88c807SRodney W. Grimesthe ``+'' operation has no effect. 2374b88c807SRodney W. GrimesIf no value is supplied for 2384b88c807SRodney W. Grimes.Ar who , 2394b88c807SRodney W. Grimeseach permission bit specified in 2404b88c807SRodney W. Grimes.Ar perm , 2414b88c807SRodney W. Grimesfor which the corresponding bit in the file mode creation mask 242dd8f42dcSRuslan Ermilov(see 243dd8f42dcSRuslan Ermilov.Xr umask 2 ) 2444b88c807SRodney W. Grimesis clear, is set. 2454b88c807SRodney W. GrimesOtherwise, the mode bits represented by the specified 2464b88c807SRodney W. Grimes.Ar who 2474b88c807SRodney W. Grimesand 2484b88c807SRodney W. Grimes.Ar perm 2494b88c807SRodney W. Grimesvalues are set. 2504b88c807SRodney W. Grimes.It \&\- 2514b88c807SRodney W. GrimesIf no value is supplied for 2524b88c807SRodney W. Grimes.Ar perm , 2534b88c807SRodney W. Grimesthe ``\-'' operation has no effect. 2544b88c807SRodney W. GrimesIf no value is supplied for 2554b88c807SRodney W. Grimes.Ar who , 2564b88c807SRodney W. Grimeseach permission bit specified in 2574b88c807SRodney W. Grimes.Ar perm , 2584b88c807SRodney W. Grimesfor which the corresponding bit in the file mode creation mask 259*244e58a2SGordon Tetlowis set, is cleared. 2604b88c807SRodney W. GrimesOtherwise, the mode bits represented by the specified 2614b88c807SRodney W. Grimes.Ar who 2624b88c807SRodney W. Grimesand 2634b88c807SRodney W. Grimes.Ar perm 2644b88c807SRodney W. Grimesvalues are cleared. 2654b88c807SRodney W. Grimes.It = 2664b88c807SRodney W. GrimesThe mode bits specified by the 2674b88c807SRodney W. Grimes.Ar who 268dd8f42dcSRuslan Ermilovvalue are cleared, or, if no 269dd8f42dcSRuslan Ermilov.Ar who 270dd8f42dcSRuslan Ermilovvalue is specified, the owner, group 2714b88c807SRodney W. Grimesand other mode bits are cleared. 2724b88c807SRodney W. GrimesThen, if no value is supplied for 2734b88c807SRodney W. Grimes.Ar who , 2744b88c807SRodney W. Grimeseach permission bit specified in 2754b88c807SRodney W. Grimes.Ar perm , 2764b88c807SRodney W. Grimesfor which the corresponding bit in the file mode creation mask 2774b88c807SRodney W. Grimesis clear, is set. 2784b88c807SRodney W. GrimesOtherwise, the mode bits represented by the specified 2794b88c807SRodney W. Grimes.Ar who 2804b88c807SRodney W. Grimesand 2814b88c807SRodney W. Grimes.Ar perm 2824b88c807SRodney W. Grimesvalues are set. 2834b88c807SRodney W. Grimes.El 2844b88c807SRodney W. Grimes.Pp 2854b88c807SRodney W. GrimesEach 2864b88c807SRodney W. Grimes.Ar clause 2874b88c807SRodney W. Grimesspecifies one or more operations to be performed on the mode 2884b88c807SRodney W. Grimesbits, and each operation is applied to the mode bits in the 2894b88c807SRodney W. Grimesorder specified. 2904b88c807SRodney W. Grimes.Pp 2914b88c807SRodney W. GrimesOperations upon the other permissions only (specified by the symbol 2924b88c807SRodney W. Grimes``o'' by itself), in combination with the 2934b88c807SRodney W. Grimes.Ar perm 2944b88c807SRodney W. Grimessymbols ``s'' or ``t'', are ignored. 295cb30dc55STom Rhodes.Pp 296cb30dc55STom RhodesThe ``w'' permission on directories will permit file creation, relocation, 297cb30dc55STom Rhodesand copy into that directory. 298cb30dc55STom RhodesFiles created within the directory itself will inherit its group ID. 2994b88c807SRodney W. Grimes.Sh EXAMPLES 3004b88c807SRodney W. Grimes.Bl -tag -width "u=rwx,go=u-w" -compact 3014b88c807SRodney W. Grimes.It Li 644 3024b88c807SRodney W. Grimesmake a file readable by anyone and writable by the owner only. 3034b88c807SRodney W. Grimes.Pp 3044b88c807SRodney W. Grimes.It Li go-w 3054b88c807SRodney W. Grimesdeny write permission to group and others. 3064b88c807SRodney W. Grimes.Pp 3074b88c807SRodney W. Grimes.It Li =rw,+X 3084b88c807SRodney W. Grimesset the read and write permissions to the usual defaults, but 3094b88c807SRodney W. Grimesretain any execute permissions that are currently set. 3104b88c807SRodney W. Grimes.Pp 3114b88c807SRodney W. Grimes.It Li +X 3124b88c807SRodney W. Grimesmake a directory or file searchable/executable by everyone if it is 3134b88c807SRodney W. Grimesalready searchable/executable by anyone. 3144b88c807SRodney W. Grimes.Pp 3154b88c807SRodney W. Grimes.It Li 755 3164b88c807SRodney W. Grimes.It Li u=rwx,go=rx 3174b88c807SRodney W. Grimes.It Li u=rwx,go=u-w 3184b88c807SRodney W. Grimesmake a file readable/executable by everyone and writable by the owner only. 3194b88c807SRodney W. Grimes.Pp 3204b88c807SRodney W. Grimes.It Li go= 3214b88c807SRodney W. Grimesclear all mode bits for group and others. 3224b88c807SRodney W. Grimes.Pp 3234b88c807SRodney W. Grimes.It Li g=u-w 3244b88c807SRodney W. Grimesset the group bits equal to the user bits, but clear the group write bit. 3254b88c807SRodney W. Grimes.El 3265bb83b98SDavid E. O'Brien.Sh COMPATIBILITY 3275bb83b98SDavid E. O'BrienThe 3285bb83b98SDavid E. O'Brien.Fl v 3295bb83b98SDavid E. O'Brienoption is non-standard and its use in scripts is not recommended. 3304b88c807SRodney W. Grimes.Sh SEE ALSO 331825e82efSJoerg Wunsch.Xr chflags 1 , 3324b88c807SRodney W. Grimes.Xr install 1 , 333745d94fcSTim J. Robbins.Xr setfacl 1 , 3344b88c807SRodney W. Grimes.Xr chmod 2 , 3354b88c807SRodney W. Grimes.Xr stat 2 , 3364b88c807SRodney W. Grimes.Xr umask 2 , 3374b88c807SRodney W. Grimes.Xr fts 3 , 3384b88c807SRodney W. Grimes.Xr setmode 3 , 339e2ea39cbSSergey Kandaurov.Xr sticky 7 , 3404b88c807SRodney W. Grimes.Xr symlink 7 , 341d5440753SJoseph Koshy.Xr chown 8 , 342e2ea39cbSSergey Kandaurov.Xr mount 8 3434b88c807SRodney W. Grimes.Sh STANDARDS 3444b88c807SRodney W. GrimesThe 345cbf6f7d3SPhilippe Charnier.Nm 3461686b602SSteve Priceutility is expected to be 3471686b602SSteve Price.St -p1003.2 3484b88c807SRodney W. Grimescompatible with the exception of the 3494b88c807SRodney W. Grimes.Ar perm 35002c724b4SBen Smithurstsymbol 3514b88c807SRodney W. Grimes.Dq t 35202c724b4SBen Smithurstwhich is not included in that standard. 353b8923d4cSWolfram Schneider.Sh HISTORY 354b8923d4cSWolfram SchneiderA 355b8923d4cSWolfram Schneider.Nm 356b8923d4cSWolfram Schneidercommand appeared in 357b8923d4cSWolfram Schneider.At v1 . 3586fca4c7cSRuslan Ermilov.Sh BUGS 35936a142c4SRuslan ErmilovThere is no 3606fca4c7cSRuslan Ermilov.Ar perm 3611b1785d4STom Rhodesoption for the naughty bits of a horse. 362