Differences between chown and chmod

Source: Internet
Author: User

I am always used to CHMOD and confuse chown.

Chown modifies the content of the first column, and chmod modifies the content of column 3 and 4.

Chown usage
Used to change the user name and user group of a directory or file
Chown User name: the path of the group name file (which can be a pair of paths or a relative path)
Example 1: chown root: Root/tmp/tmp1
Change the user name and user group of tmp1 under TMP to root and root (only the group of tmp1 is modified ).
Example 2: chown-r root: Root/tmp/tmp1
The group of all objects in tmp1 under TMP is changed to root and root.

Chmod usage
Used to modify the access permissions of a directory or file.
Syntax: chmod [who] [+ |-| =] [mode] File Name
The meaning of each option in the command is:
The operator who is one of the following letters or their combination:
U indicates "user", that is, the owner of a file or directory.
G indicates "group users", that is, all users with the same group ID as the file owner.
O indicates "Other (Others) Users ".
A Indicates "All (all) Users ". It is the default value of the system.
The operation symbol can be:
+ Add a permission.
-Cancel a permission.
= Grant the given permission and cancel all other permissions (if any ).
Set the permissions indicated by mode to any combination of the following letters:
R readable.
W writable.
X executable.
X adds the X attribute only when the target file is executable to some users or the target file is a directory.
S sets the owner or group ID of the process to the file owner during file execution.
In the format of "U + S" to set the user ID of the file, and "G + S" to set the group ID.
T save the program text to the swap device.
U has the same permissions as the file owner.
G. users in the same group have the same permissions as file owners.
O has the same permissions as other users.

File Name: list of files separated by spaces to change permissions. Wildcards are supported.

Reference: http://hi.baidu.com/whn_arthur/item/6ce34137321e2385b711db27

 

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.