Linux--chmod

Source: Internet
Author: User

CHMOD (1) User Commands CHMOD (1)



NAME
Chmod-change File Mode bits

Synopsis
chmod [OPTION] ... Mode[,mode] ... FILE ...
chmod [OPTION] ... Octal-mode FILE ...
chmod [OPTION] ...--reference=rfile FILE ...

DESCRIPTION
This manual page documents the GNU version of chmod. chmod changes the file mode bits of each given file according to mode, which can is
Either a symbolic representation of changes to make, or an octal number representing the bit pattern for the new mode bits .

The format of a symbolic mode is [Ugoa ...] [[+-=][perms ...] ...], where perms is either zero or more letters from the set RWXXST, or a single
Letter from the set Ugo. Multiple symbolic modes can be given, separated by commas.

A combination of the letters UGOA controls which users ' access to the file would be changed:the user who owns it (U), Other users in the
File ' s Group (g), other users not in the file's group (o), or all users (a). If none of these is given, the effect is as if a were given,
But bits is set in the umask is not affected.

The operator + causes the selected file mode bits to is added to the existing file mode bits for each file; -Causes them to be removed; and
= causes them to is added and causes unmentioned bits to is removed except that a directory ' s unmentioned set user and Gro Up ID bits is not
affected.

The letters RWXXST Select File mode bits for the affected Users:read (R), write (W), execute (or search for dire ctories) (x), exe‐
Cute/search only if the file is a directory or already have Execute permission for some user (X), set user or group ID o n Execution (s),
Restricted deletion flag or sticky bit (t). Instead of one or more of these letters, you can specify exactly one of the letters ugo:the
Permissions granted to the user owns the file (U), the permissions granted to other users S Group (g), and
The permissions granted to users and that is in neither of the and the preceding categories (O).

A numeric mode is from one to four octal digits (0-7), derived by adding-the bits with values 4, 2, and 1. Omitted digits is assumed to
be leading zeros.   The first digit selects the Set User ID (4) and set group ID (2) and restricted deletion or sticky (1) attributes. The
Second digit selects permissions for the user who owns the File:read (4), write (2), and execute (1); The third selects permissions for
Other users in the file ' s group, with the same values; The fourth for other users is not in the file ' s group, with the same values.

chmod never changes the permissions of symbolic links;  The chmod system call cannot change their permissions. This is a problem since
The permissions of symbolic links are never used. However symbolic link listed on the command line, chmod changes the permissions
of the pointed-to file. In contrast, chmod ignores symbolic links encountered during recursive directory traversals.

SETUID and SETGID BITS
chmod clears the Set-group-id bit of a regular file if the file ' s group ID does not match the user ' s effective group ID or One of the user ' s
Supplementary group IDs, unless the user has appropriate privileges. Additional restrictions may cause the Set-user-id and Set-group-id
bits of MODE or rfile to is ignored.   This behavior depends in the policy and functionality of the underlying CHMOD system call. When in
Doubt, check the underlying system behavior.

chmod preserves a directory ' s Set-user-id and Set-group-id bits unless you explicitly specify otherwise. can set or clear the bits with
Symbolic modes like U+s and G-s, and can set (but not clear) the bits with a numeric mode.

RESTRICTED deletion FLAG OR STICKY BIT
The restricted deletion flag or sticky bit is a single bit and whose interpretation depends on the file type. For directories, it prevents
unprivileged users from removing or renaming a file in the directory unless they own the file or the directory; This is called the
Restricted deletion flag for the directory, and are commonly found on world-writable directories like/tmp. For regular files on some older
Systems, the bit saves the program's text image on the swap device so it would load more quickly when run; This is called the sticky bit.

OPTIONS
Change the mode of each FILE to mode. With--reference, change the mode of each FILE to that of Rfile.

-C,--changes
Like verbose, but the report has a change is made

-F,--silent,--quiet
Suppress most error messages

-V,--verbose
Output a diagnostic for every file processed

--no-preserve-root
Do not treat '/' specially (the default)

--preserve-root
Fail to operate recursively on '/'

--reference=rfile
Use Rfile ' s mode instead of mode values

-R,--recursive
Change files and directories recursively

--help Display this Help and exit

--version
Output version information and exit

Each MODE is of the form ' [ugoa]* ([-+=]([rwxxst]*| [Ugo]      ))+    | [-+=] [0-7]+ '.

  

1 #chmod u=rwx,g=rw,o=r  file23 #chmod a=r file     All users plus readable properties
1$ chmod u+x file adds execute permission to the owner of file2$ chmod751File assigns read, write, and execute to the owner of the file (7), assign read and execute to the group where the file is located (5), assigning execution to other users (1) of Permissions3$ chmod u=rwx,g=rx,o=another form of x file above example4$ chmod =r file assigns read permissions to all users5$ chmod444File above example6$ chmod a-wx,a+r file above example7$ chmod-r u+r directory recursively assigns read permissions to the owner of all files and subdirectories in the directory directory8$ chmod4755Set the ID, assign read, write and execute permissions to the owner, and assign read and execute permissions to the group and other users.
From:
Http://www.cnblogs.com/younes/archive/2009/11/20/1607174.html



AUTHOR
Written by David MacKenzie and Jim meyering.

REPORTING BUGS
Report chmod bugs to [email protected]
GNU coreutils Home page: General help using GNU software: Report chmod translation Bugs to
COPYRIGHT
copyright©2013 Free Software Foundation, Inc. License gplv3+: GNU GPL version 3 or later This was free software:you was free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.

See ALSO
chmod (2)

The full documentation-CHMOD is maintained as a Texinfo manual. If the info and chmod programs is properly installed at your site, the
Command

Info coreutils ' chmod invocation '

Should give you access to the complete manual.



GNU Coreutils 8.21 March 2014 CHMOD (1)

Linux--chmod

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.