1'\" Copyright (C) 1998-1999, 2001, 2006-2007, 2009-2010 Free Software 2'\" Foundation, Inc. 3'\" 4'\" This is free software. You may redistribute copies of it under the terms 5'\" of the GNU General Public License <http://www.gnu.org/licenses/gpl.html>. 6'\" There is NO WARRANTY, to the extent permitted by law. 7[NAME] 8chmod \- change file mode bits 9[DESCRIPTION] 10This manual page 11documents the GNU version of 12.BR chmod . 13.B chmod 14changes the file mode bits of each given file according to 15.IR mode , 16which can be either a symbolic representation of changes to make, or 17an octal number representing the bit pattern for the new mode bits. 18.PP 19The format of a symbolic mode is [\c 20\fBugoa\fP.\|.\|.][[\fB+-=\fP][\fIperms\fP.\|.\|.].\|.\|.], 21where 22.I "perms" 23is either zero or more letters from the set 24\fBrwxXst\fP, or a single letter from the set \fBugo\fP. 25Multiple symbolic 26modes can be given, separated by commas. 27.PP 28A combination of the letters \fBugoa\fP controls which users' access 29to the file will be changed: the user who owns it (\fBu\fP), other 30users in the file's group (\fBg\fP), other users not in the file's 31group (\fBo\fP), or all users (\fBa\fP). If none of these are given, 32the effect is as if \fBa\fP were 33given, but bits that are set in the umask are not affected. 34.PP 35The operator \fB+\fP causes the selected file mode bits to be added to 36the existing file mode bits of each file; \fB-\fP causes them to be 37removed; and \fB=\fP causes them to be added and causes unmentioned 38bits to be removed except that a directory's unmentioned set user and 39group ID bits are not affected. 40.PP 41The letters \fBrwxXst\fP select file mode bits for the affected users: 42read (\fBr\fP), write (\fBw\fP), execute (or search for directories) 43(\fBx\fP), execute/search only if the file is a directory or already 44has execute permission for some user (\fBX\fP), set user or group ID 45on execution (\fBs\fP), restricted deletion flag or sticky bit 46(\fBt\fP). Instead of one or more of these letters, you can specify 47exactly one of the letters \fBugo\fP: the permissions granted to the 48user who owns the file (\fBu\fP), the permissions granted to other 49users who are members of the file's group (\fBg\fP), 50and the permissions granted to users that are in neither of the two preceding 51categories (\fBo\fP). 52.PP 53A numeric mode is from one to four octal digits (0\-7), derived by 54adding up the bits with values 4, 2, and 1. Omitted digits are 55assumed to be leading zeros. 56The first digit selects the set user ID (4) and set group ID (2) and 57restricted deletion or sticky (1) attributes. The second digit 58selects permissions for the user who owns the file: read (4), write (2), 59and execute (1); the third selects permissions for other users in the 60file's group, with the same values; and the fourth for other users not 61in the file's group, with the same values. 62.PP 63.B chmod 64never changes the permissions of symbolic links; the 65.B chmod 66system call cannot change their permissions. This is not a problem 67since the permissions of symbolic links are never used. 68However, for each symbolic link listed on the command line, 69.B chmod 70changes the permissions of the pointed-to file. 71In contrast, 72.B chmod 73ignores symbolic links encountered during recursive directory 74traversals. 75.SH "SETUID AND SETGID BITS" 76.B chmod 77clears the set-group-ID bit of a 78regular file if the file's group ID does not match the user's 79effective group ID or one of the user's supplementary group IDs, 80unless the user has appropriate privileges. Additional restrictions 81may cause the set-user-ID and set-group-ID bits of 82.I MODE 83or 84.I RFILE 85to be ignored. This behavior depends on the policy and 86functionality of the underlying 87.B chmod 88system call. When in 89doubt, check the underlying system behavior. 90.PP 91.B chmod 92preserves a directory's set-user-ID and set-group-ID bits unless you 93explicitly specify otherwise. You can set or clear the bits with 94symbolic modes like 95.B u+s 96and 97.BR g\-s , 98and you can set (but not clear) the bits with a numeric mode. 99.SH "RESTRICTED DELETION FLAG OR STICKY BIT" 100The restricted deletion flag or sticky bit is a single bit, whose 101interpretation depends on the file type. For directories, it prevents 102unprivileged users from removing or renaming a file in the directory 103unless they own the file or the directory; this is called the 104.I "restricted deletion flag" 105for the directory, and is commonly found on world-writable directories 106like \fB/tmp\fP. For regular files on some older systems, the bit 107saves the program's text image on the swap device so it will load more 108quickly when run; this is called the 109.IR "sticky bit" . 110.SH OPTIONS 111[SEE ALSO] 112chmod(2) 113