logo

utils-std

Collection of commonly available Unix tools git clone https://anongit.hacktivis.me/git/utils-std.git

chmod.1 (2924B)


  1. .\" utils-std: Collection of commonly available Unix tools
  2. .\" Copyright 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
  3. .\" SPDX-License-Identifier: MPL-2.0
  4. .Dd 2024-03-12
  5. .Dt CHMOD 1
  6. .Os
  7. .Sh NAME
  8. .Nm chmod
  9. .Nd Change files modes
  10. .Sh SYNOPSIS
  11. .Nm
  12. .Op Fl cRv
  13. .Ar mode
  14. .Ar file...
  15. .Sh DESCRIPTION
  16. .Nm
  17. sets the permissions bits given by
  18. .Ar mode
  19. on each given
  20. .Ar file .
  21. .Pp
  22. .Ar mode
  23. can be either an octal natural number between 0 and 7777, or a symbolic operation like
  24. .Ql +r
  25. or
  26. .Ql g=o-x .
  27. See the
  28. .Sx OCTAL MODE
  29. and
  30. .Sx SYMBOLIC OPERATIONS
  31. sections for details.
  32. .Pp
  33. If
  34. .Ar mode
  35. starts with a dash (or is user-provided), it should be broken from options with a preceding double-dash
  36. .Pq --
  37. like so:
  38. .Dl chmod -v -- -w,+r foobar
  39. .Sh OPTIONS
  40. .Bl -tag -width Ds
  41. .It Fl c
  42. Print mode changes
  43. .It Fl R
  44. Recurse into directories passed to
  45. .It Fl v
  46. Verbose, print both changes and retained modes
  47. .Ar file
  48. .El
  49. .Sh OCTAL MODE
  50. Octal natural number between 0 and 7777, which can be obtained by or'ing the following values:
  51. .br
  52. .Bl -tag -width 0000 -compact
  53. .It 4000
  54. setuid
  55. .It 2000
  56. setgid
  57. .It 1000
  58. sticky bit
  59. .It 0400
  60. user read
  61. .It 0200
  62. user write
  63. .It 0100
  64. user execute/search
  65. .It 0070
  66. group read, write, execute/search
  67. .It 0007
  68. others read, write, execute/search
  69. .El
  70. .Sh SYMBOLIC OPERATIONS
  71. Uses the following grammar:
  72. .Bd -literal
  73. mode ::= clause [',' clause]*
  74. clause ::= who* action+
  75. action ::= [op | op perm+ | op permcopy]
  76. who ::= 'u' | 'g' | 'o' | 'a'
  77. op ::= '+' | '-' | '='
  78. perm ::= 'r' | 'w' | 'x' | 'X' | 's' | 't'
  79. permcopy ::= 'u' | 'g' | 'o'
  80. .Ed
  81. .Pp
  82. Which corresponds to:
  83. .Bl -tag -width permcopy
  84. .It mode
  85. List of
  86. .Ql clause
  87. to apply, each separated by a comma.
  88. .Pp
  89. For example
  90. .Ql g+r,o=g
  91. sets read permission for group part and copies to other part the resulting permissions of the group part.
  92. .It clause
  93. Optionally starts with
  94. .Ql who
  95. and contains one or more
  96. .Ql action .
  97. .Pp
  98. When
  99. .Ql who
  100. isn't given,
  101. .Xr umask 3
  102. is followed similarly to file creation.
  103. .It action
  104. Always starts with
  105. .Ql op ,
  106. optionally followed by either one or more
  107. .Ql perm ,
  108. or a single
  109. .Ql permcopy
  110. .It who
  111. user(u), group(g), other(o), all(a)
  112. .It op
  113. Operation to apply: add(+), del(-), set(=)
  114. .Pp
  115. When neither
  116. .Ql perm
  117. nor
  118. .Ql permcopy
  119. were given, set(=) clears all permissions.
  120. .It perm
  121. which permissions to assign:
  122. .Bl -tag -width X -compact
  123. .It r
  124. Read
  125. .It w
  126. Write
  127. .It x
  128. Execute/Search
  129. .It X
  130. Search (directories-only)
  131. .It s
  132. Setuid when assigned to user, setgid when assigned to group
  133. .It t
  134. Sticky bit
  135. .El
  136. .It permcopy
  137. who to copy permissions from: user(u), group(g), other(o)
  138. .El
  139. .Sh EXIT STATUS
  140. .Ex -std
  141. .Sh SEE ALSO
  142. .Xr stat 1
  143. .Sh STANDARDS
  144. .Nm
  145. should be compliant with the
  146. IEEE Std 1003.1-2024 (“POSIX.1”)
  147. specification.
  148. .Pp
  149. The
  150. .Fl c
  151. and
  152. .Fl v
  153. options are present for compatibility with other modern systems such as BusyBox and GNU coreutils.
  154. .Sh AUTHORS
  155. .An Haelwenn (lanodan) Monnier Aq Mt contact+utils@hacktivis.me