| 1 |
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.50.1. |
| 2 |
.TH CHMOD "1" "February 2026" "GNU coreutils 9.10" "User Commands" |
| 3 |
.SH NAME |
| 4 |
chmod \- change file mode bits |
| 5 |
.SH SYNOPSIS |
| 6 |
.B chmod |
| 7 |
[\fI\,OPTION\/\fR]... \fI\,MODE\/\fR[\fI\,,MODE\/\fR]... \fI\,FILE\/\fR... |
| 8 |
.br |
| 9 |
.B chmod |
| 10 |
[\fI\,OPTION\/\fR]... \fI\,OCTAL-MODE FILE\/\fR... |
| 11 |
.br |
| 12 |
.B chmod |
| 13 |
[\fI\,OPTION\/\fR]... \fI\,--reference=RFILE FILE\/\fR... |
| 14 |
.SH DESCRIPTION |
| 15 |
This manual page |
| 16 |
documents the GNU version of |
| 17 |
.BR chmod . |
| 18 |
.B chmod |
| 19 |
changes the file mode bits of each given file according to |
| 20 |
.IR mode , |
| 21 |
which can be either a symbolic representation of changes to make, or |
| 22 |
an octal number representing the bit pattern for the new mode bits. |
| 23 |
.PP |
| 24 |
The format of a symbolic mode is [\c |
| 25 |
\fBugoa\fP.\|.\|.][[\fB-+=\fP][\fIperms\fP.\|.\|.].\|.\|.], |
| 26 |
where |
| 27 |
.I "perms" |
| 28 |
is either zero or more letters from the set |
| 29 |
\fBrwxXst\fP, or a single letter from the set \fBugo\fP. |
| 30 |
Multiple symbolic |
| 31 |
modes can be given, separated by commas. |
| 32 |
.PP |
| 33 |
A combination of the letters \fBugoa\fP controls which users' access |
| 34 |
to the file will be changed: the user who owns it (\fBu\fP), other |
| 35 |
users in the file's group (\fBg\fP), other users not in the file's |
| 36 |
group (\fBo\fP), or all users (\fBa\fP). If none of these are given, |
| 37 |
the effect is as if (\fBa\fP) were |
| 38 |
given, but bits that are set in the umask are not affected. |
| 39 |
.PP |
| 40 |
The operator \fB+\fP causes the selected file mode bits to be added to |
| 41 |
the existing file mode bits of each file; \fB-\fP causes them to be |
| 42 |
removed; and \fB=\fP causes them to be added and causes unmentioned |
| 43 |
bits to be removed except that a directory's unmentioned set user and |
| 44 |
group ID bits are not affected. |
| 45 |
.PP |
| 46 |
The letters \fBrwxXst\fP select file mode bits for the affected users: |
| 47 |
read (\fBr\fP), write (\fBw\fP), execute (or search for directories) |
| 48 |
(\fBx\fP), execute/search only if the file is a directory or already |
| 49 |
has execute permission for some user (\fBX\fP), set user or group ID |
| 50 |
on execution (\fBs\fP), restricted deletion flag or sticky bit |
| 51 |
(\fBt\fP). Instead of one or more of these letters, you can specify |
| 52 |
exactly one of the letters \fBugo\fP: the permissions granted to the |
| 53 |
user who owns the file (\fBu\fP), the permissions granted to other |
| 54 |
users who are members of the file's group (\fBg\fP), |
| 55 |
and the permissions granted to users that are in neither of the two preceding |
| 56 |
categories (\fBo\fP). |
| 57 |
.PP |
| 58 |
A numeric mode is from one to four octal digits (0\-7), derived by |
| 59 |
adding up the bits with values 4, 2, and 1. Omitted digits are |
| 60 |
assumed to be leading zeros. |
| 61 |
The first digit selects the set user ID (4) and set group ID (2) and |
| 62 |
restricted deletion or sticky (1) attributes. The second digit |
| 63 |
selects permissions for the user who owns the file: read (4), write (2), |
| 64 |
and execute (1); the third selects permissions for other users in the |
| 65 |
file's group, with the same values; and the fourth for other users not |
| 66 |
in the file's group, with the same values. |
| 67 |
.PP |
| 68 |
.B chmod |
| 69 |
doesn't change the permissions of symbolic links; the |
| 70 |
.B chmod |
| 71 |
system call cannot change their permissions on most systems, |
| 72 |
and most systems ignore permissions of symbolic links. |
| 73 |
However, for each symbolic link listed on the command line, |
| 74 |
.B chmod |
| 75 |
changes the permissions of the pointed-to file. |
| 76 |
In contrast, |
| 77 |
.B chmod |
| 78 |
ignores symbolic links encountered during recursive directory |
| 79 |
traversals. Options that modify this behavior are described in the |
| 80 |
.B OPTIONS |
| 81 |
section. |
| 82 |
.SH "SETUID AND SETGID BITS" |
| 83 |
.B chmod |
| 84 |
clears the set-group-ID bit of a |
| 85 |
regular file if the file's group ID does not match the user's |
| 86 |
effective group ID or one of the user's supplementary group IDs, |
| 87 |
unless the user has appropriate privileges. Additional restrictions |
| 88 |
may cause the set-user-ID and set-group-ID bits of |
| 89 |
.I MODE |
| 90 |
or |
| 91 |
.I RFILE |
| 92 |
to be ignored. This behavior depends on the policy and |
| 93 |
functionality of the underlying |
| 94 |
.B chmod |
| 95 |
system call. When in |
| 96 |
doubt, check the underlying system behavior. |
| 97 |
.PP |
| 98 |
For directories |
| 99 |
.B chmod |
| 100 |
preserves set-user-ID and set-group-ID bits unless you |
| 101 |
explicitly specify otherwise. You can set or clear the bits with |
| 102 |
symbolic modes like |
| 103 |
.B u+s |
| 104 |
and |
| 105 |
.BR g\-s . |
| 106 |
To clear these bits for directories with a numeric mode requires |
| 107 |
an additional leading zero like |
| 108 |
.BR 00755 , |
| 109 |
leading minus like |
| 110 |
.BR \-6000 , |
| 111 |
or leading equals like |
| 112 |
.BR =755 . |
| 113 |
.SH "RESTRICTED DELETION FLAG OR STICKY BIT" |
| 114 |
The restricted deletion flag or sticky bit is a single bit, whose |
| 115 |
interpretation depends on the file type. For directories, it prevents |
| 116 |
unprivileged users from removing or renaming a file in the directory |
| 117 |
unless they own the file or the directory; this is called the |
| 118 |
.I "restricted deletion flag" |
| 119 |
for the directory, and is commonly found on world-writable directories |
| 120 |
like \fB/tmp\fP. For regular files on some older systems, the bit |
| 121 |
saves the program's text image on the swap device so it will load more |
| 122 |
quickly when run; this is called the |
| 123 |
.IR "sticky bit" . |
| 124 |
.SH OPTIONS |
| 125 |
.PP |
| 126 |
Change the mode of each FILE to MODE. |
| 127 |
With \fB\-\-reference\fR, change the mode of each FILE to that of RFILE. |
| 128 |
.TP |
| 129 |
\X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#chmod-c'\fB\-c, \-\-changes\fP\X'tty: link' |
| 130 |
like verbose but report only when a change is made |
| 131 |
.TP |
| 132 |
\X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#chmod-f'\fB\-f, \-\-silent, \-\-quiet\fP\X'tty: link' |
| 133 |
suppress most error messages |
| 134 |
.TP |
| 135 |
\X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#chmod-v'\fB\-v, \-\-verbose\fP\X'tty: link' |
| 136 |
output a diagnostic for every file processed |
| 137 |
.TP |
| 138 |
\X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#chmod--dereference'\fB\-\-dereference\fP\X'tty: link' |
| 139 |
affect the referent of each symbolic link, |
| 140 |
rather than the symbolic link itself |
| 141 |
.TP |
| 142 |
\X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#chmod-h'\fB\-h, \-\-no\-dereference\fP\X'tty: link' |
| 143 |
affect each symbolic link, rather than the referent |
| 144 |
.TP |
| 145 |
\X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#chmod--no-preserve-root'\fB\-\-no\-preserve\-root\fP\X'tty: link' |
| 146 |
do not treat '/' specially (the default) |
| 147 |
.TP |
| 148 |
\X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#chmod--preserve-root'\fB\-\-preserve\-root\fP\X'tty: link' |
| 149 |
fail to operate recursively on '/' |
| 150 |
.TP |
| 151 |
\X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#chmod--reference'\fB\-\-reference=RFILE\fP\X'tty: link' |
| 152 |
use RFILE's mode instead of specifying MODE values. |
| 153 |
RFILE is always dereferenced if a symbolic link. |
| 154 |
.TP |
| 155 |
\X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#chmod-R'\fB\-R, \-\-recursive\fP\X'tty: link' |
| 156 |
change files and directories recursively |
| 157 |
.PP |
| 158 |
The following options modify how a hierarchy is traversed when the \fB\-R\fR |
| 159 |
option is also specified. If more than one is specified, only the final |
| 160 |
one takes effect. \fB\-H\fR is the default. |
| 161 |
.TP |
| 162 |
\X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#chmod-H'\fB\-H\fP\X'tty: link' |
| 163 |
if a command line argument is a symlink to a directory, traverse it |
| 164 |
.TP |
| 165 |
\X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#chmod-L'\fB\-L\fP\X'tty: link' |
| 166 |
traverse every symbolic link to a directory encountered |
| 167 |
.TP |
| 168 |
\X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#chmod-P'\fB\-P\fP\X'tty: link' |
| 169 |
do not traverse any symbolic links |
| 170 |
.TP |
| 171 |
\X'tty: link https://www.gnu.org/software/coreutils/chmod#chmod--help'\fB\-\-help\fP\X'tty: link' |
| 172 |
display this help and exit |
| 173 |
.TP |
| 174 |
\X'tty: link https://www.gnu.org/software/coreutils/chmod#chmod--version'\fB\-\-version\fP\X'tty: link' |
| 175 |
output version information and exit |
| 176 |
.PP |
| 177 |
Each MODE is of the form '[ugoa]*([\-+=]([rwxXst]*|[ugo]))+|[\-+=][0\-7]+'. |
| 178 |
.SH AUTHOR |
| 179 |
Written by David MacKenzie and Jim Meyering. |
| 180 |
.SH "REPORTING BUGS" |
| 181 |
Report bugs to: bug\[email protected] |
| 182 |
.br |
| 183 |
GNU coreutils home page: <https://www.gnu.org/software/coreutils/> |
| 184 |
.br |
| 185 |
General help using GNU software: <https://www.gnu.org/gethelp/> |
| 186 |
.br |
| 187 |
Report any translation bugs to <https://translationproject.org/team/> |
| 188 |
.SH "SEE ALSO" |
| 189 |
\fBchmod\fP(2) |
| 190 |
.PP |
| 191 |
.br |
| 192 |
Full documentation <https://www.gnu.org/software/coreutils/chmod> |
| 193 |
.br |
| 194 |
or available locally via: info \(aq(coreutils) chmod invocation\(aq |
| 195 |
.PP |
| 196 |
.br |
| 197 |
Packaged by Debian (9.10\-1) |
| 198 |
.br |
| 199 |
Copyright \(co 2026 Free Software Foundation, Inc. |
| 200 |
.br |
| 201 |
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>. |
| 202 |
.br |
| 203 |
This is free software: you are free to change and redistribute it. |
| 204 |
.br |
| 205 |
There is NO WARRANTY, to the extent permitted by law. |