< Day Day Up > |
Recipe 9.4. Setting File and Directory Permissions with chmod's Symbolic Notation9.4.1 ProblemYou would like to change specific permission bits, rather than using the all-or-nothing approach of chmod's numeric notation, such as marking a script as executable. 9.4.2 SolutionThe most common use for symbolic notation is to add the executable bit to a file's permissions without changing any other permissions: $ chmod +x scriptname The default action is a, or all, so the example makes scriptname executable by everyone. This adds the executable bit to the file owner only: $ chmod u+x scriptname You can surgically remove a specific mode bit. In this example, the group and other users lose their executable bits: $ chmod go-x scriptname This is a quick way to set the setgid bit on a directory, for creating a shared directory. All files created in this directory will have the same group ownership as the directory: $ chmod +s /shared-directory You can remove all permissions for group and other users by doing the following: $ chmod go= scriptname To make group permissions the same as the file owner's, use: $ chmod g=u scriptname 9.4.3 DiscussionUsing chmod's symbolic notation can get quite elaborate. This examples erases all existing permissions and starts over: $ chmod -v a=,u=rwx,g=rx,o=r scriptname You can do the same thing with chmod 754. Here's the key: Symbolic notation is also called mnemonic notation:
9.4.4 See Also
|
< Day Day Up > |