logo

utils-std

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

chmod.1 (2107B)


  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 (ie. 0644 for rw-r--r--), or a symbolic operation, like
  24. .Ql +r or
  25. .Ql g=o-x ,
  26. see
  27. .Sx SYMBOLIC OPERATIONS
  28. section for more information.
  29. .Pp
  30. If
  31. .Ar mode
  32. starts with a dash (or is user-provided), it should be broken from options with a preceeding double-dash
  33. .Pq --
  34. like so:
  35. .Dl chmod -v -- -w,+r foobar
  36. .Sh OPTIONS
  37. .Bl -tag -width Ds
  38. .It Fl c
  39. Print mode changes
  40. .It Fl R
  41. Recurse into directories passed to
  42. .It Fl v
  43. Verbose, print both changes and retained modes
  44. .Ar file
  45. .El
  46. .Sh SYMBOLIC OPERATIONS
  47. Roughly corresponds to the following regex:
  48. .Ql ((^|,)[ugoa]*([+-=][ugo]|[+-=][rwxXst]+)+)+
  49. .Bl -tag -width Ds
  50. .It ,
  51. Separator between each operation,
  52. .Ql g+r,o=g
  53. sets read for group and copies to other the resulting permissions of group.
  54. .It [ugoa]
  55. who: Sets who to assign permissions to.
  56. .It [+-=]
  57. op: Respectively add(+), del(-), set(=).
  58. .Pp
  59. When who isn't given,
  60. .Xr umask 3
  61. is followed similarly to file creation.
  62. When neither permcopy nor permlist is given, set(=) clears all permissions.
  63. .It [ugo]
  64. permcopy: Sets who to copy permissions from.
  65. .It [rwxXst]+
  66. permlist: Sets which permissions to assign, respectively:
  67. .Bl -tag -width X
  68. .It r
  69. Read
  70. .It w
  71. Write
  72. .It x
  73. Execute/Search
  74. .It X
  75. Search (directories-only)
  76. .It s
  77. Setuid when assigned to user, setgid when assigned to group.
  78. .It t
  79. Sticky bit.
  80. .El
  81. .El
  82. .Sh EXIT STATUS
  83. .Ex -std
  84. .Sh SEE ALSO
  85. .Xr stat 1
  86. .Sh STANDARDS
  87. .Nm
  88. should be compliant with the
  89. IEEE Std 1003.1-2024 (“POSIX.1”)
  90. specification.
  91. .Pp
  92. The
  93. .Fl c
  94. and
  95. .Fl v
  96. options are present for compatibility with other modern systems such as BusyBox and GNU coreutils.
  97. .Sh AUTHORS
  98. .An Haelwenn (lanodan) Monnier Aq Mt contact+utils@hacktivis.me