Linux chmod Command Detailed

Source: Internet
Author: User

chmod----Changing the access mode of one or more files (mode) chmod [options] mode files  can only be used by a file owner or a privileged user to change the file access mode. Mode can be expressed in digital form or in the form of who opcode permission. Who is optional and the default is a (all users). Only one opcode (opcode) can be selected. Multiple mode can be specified, separated by commas.  options: -c,--changes only outputs the information of the changed file  -f,--silent,--quiet when chmod cannot change the file mode, the user who does not notify the file  --help output help information.  -r,--recursive can recursively traverse subdirectories to set permissions for all files and subdirectories under the directory  --reference=filename refer to filename permissions  -v,-- Verbose regardless of whether the modification is successful, output information  --version output version information for each file.  who u User  g Group  o other  a all users (default)  opcode + Add permissions  -Remove permissions  = reassign permissions   Permission r Read  w Write  x execute  s set User (or group) ID number  t set sticky bit (sticky bit) to prevent files or directories from being non-primary delete  u user's current permissions The current permissions of the  G group  o other users ' current permissions   as a choice, most of us use the form of three-bit octal digits to represent permissions, the first to specify the owner's permission, the second to specify the group permissions, the third to specify the permissions of the other user, each pass 4 (read), 2 (write), 1 ( Execute) Three numeric values and to determine the permissions. If 6 (4+2) represents a read-write right, 7 (4+2+1) has read, write, and execute permissions.   can also set the fourth bit, which is in front of the three-bit permission sequence, and the fourth digit value is 4,2,1, which means:  4, set the user ID at execution time to authorize the file owner-based process, not to the user who created the process.  2, when executed, sets the user group ID, which is used to authorize processes based on the group of files, rather than on the user who created the process.  1, set the sticky bit.   Example:  $ chmod u+x file                  Add executive permissions to file owner $ chmod 751 file               &NBS    P   Assign read, write, execute (7) permissions to the owner of file, assign Read, execute (5) permissions to the group where the file is located, assign permissions to other users to execute (1) $ chmod u=rwx,g=rx,o=x file       Another form of the above example $ chmod =r file                 To assign Read permissions to all users $ chmod 444 file   &nbs P           Previous $ chmod a-wx,a+r   file       Previous example $ chmod-r u+r directory         Recursively read permissions for the owner of all files and subdirectories under Directory directory chmod 4755             &NB Sp             Set the ID to assign read, write, and execute permissions to the owner and assign read and execute permissions to the group and other users.

Detailed instructions for Linux chmod commands

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.