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, change the changes to all files and subdirectories in the directory--reference=filename refer to the permissions of filename to set permissions-v,--verbose regardless of the success of the modification, output each file information-- Version output information. Who u user G Group O other a All users (default) opcode + Add permissions-delete 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 deleted by non-owner U Current permissions of the user G Group O Other users of the current permissions as a choice, we most of the three-bit octal number to represent the permissions, the first to specify the permissions of the master, the second to specify the permissions of the group, the third to specify the permissions of other users, each through 4 (read), 2 (write), 1 (execution) Three 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. You can also set the fourth bit, which is in front of the three-bit permission sequence, and the fourth digit value is a combination of 4,2,1, which means the following:
 


a-setuid bit, if the bit is 1, then set setuid (4)
b-setgid bit, if the bit is 1, indicates that the setting Setgid (2)
c-sticky bit, if the bit is 1, the setting sticky (1)
setuid: Sets the file owner's permissions for files in the execution phase. Typical files are/usr/bin/passwd. If the file is executed by an average user, The file can be rooted to change the user's password.

setgid: This permission is valid only for the directory. After the directory is set, any user who creates the file in this directory has the same group as the group to which the directory belongs.
sticky bit: This bit can be understood as an anti-delete bit. Whether a file can be deleted by a user depends primarily on whether the group to which the file belongs has write access to the user.

Span style= "FONT-SIZE:14PX;" > You can use the sticky bit bit for the file. When this bit is set, the file cannot be deleted even if the user has write access to the directory.
Example: $ chmod u+x file to the owner of file add Execute permission $ chmod 751 file to the owner of the file to assign read, write, execute (7) permission, to file To assign Read, execute (5) permissions to other users, assign execute (1) permissions to the chmod u=rwx,g=rx,o=x file in another form of $ chmod =r file to assign Read permissions to all users $ c Hmod 444 File Above example $ chmod a-wx,a+r file above example $ chmod-r u+r directory recursively to directory directory The owner-assigned Read permissions for all files and subdirectories are set with the ID, assign read, write, and execute permissions to the owner, and assign read and execute permissions to the group and other users. chmod 4755.

Linux chmod Command Detailed

Related Article

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.