Linux chmod Command Detailed

Source: Internet
Author: User

chmod [options] mode files

This feature 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              output only 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             

--reference=filename    set permissions by referencing the permissions of the filename

-v,--verbose output information for each file, regardless of whether the modification was successful

--version output version information.

Who

u user

Group G

o Other

A All users (default)

OpCode

+ Add Permissions

-Delete Permissions

= Reassign Permissions

Permission

R Read

W Write

X execution

s sets the ID number of the user (or group)

T set the sticky bit (sticky bit) to prevent files or directories from being deleted by non-owner

U user's current permissions

Current permissions for Group G

o Other users ' current permissions

As a choice, most of us represent permissions in the form of three-bit octal digits, the first one specifying the permissions of the master, the second specifying the group permissions, and the third specifying the permissions of the other user, each of which is determined by 4 (read), 2 (write), 1 (executed), and three numeric values. If 6 (4+2) represents a read-write right, 7 (4+2+1) has read, write, and execute permissions.

You 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 the following:

4, the user ID is set at execution time, and is used to authorize the file owner-based process instead of the user who created the process.

2, when executed, sets the user group ID, which is used to authorize the process based on the group of files, rather than on the user who created the process.

1, set the sticky bit.

Instance:

$ chmod u+x file adds execute permission to the owner of file

$ chmod 751 file assigns read, write, execute (7) permissions to the owner of file, assigns read, execute (5) permissions to the group where the file resides, and assigns permissions to other users to execute (1)

$ chmod Another form of the example on U=rwx,g=rx,o=x file

$ chmod =r file to assign Read permissions to all users

$ chmod 444 File above example

$ chmod a-wx,a+r File above example

$ chmod-r u+r Directory recursively reads permissions for the owner of all files and subdirectories in directory directory

$ chmod 4755 Sets the ID to assign read, write, and execute permissions to the owner, assigning read and Execute permissions to the group and other users.



Linux chmod Command Detailed

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.