The difference and usage of chown and chmod in Linux

Source: Internet
Author: User

chmod Modify the first column of content,chown Modify the contents of 3rd, 4 columns:

Chown usage:

The user name and user group used to change a directory or file.

Chown User name: Group name file path (can be an absolute path or a relative path)

Example 1:chown ROOT:ROOT/TMP/TMP1

is to change the TMP1 username and user Group under TMP to root and root (only the genus Group of TMP1 is modified).

Example 2:chown-r ROOT:ROOT/TMP/TMP1

is to change the group of all files under TMP1 under TMP to root and root.

chmod usage:

Used to modify access permissions for a directory or file.

Syntax: chmod [-CFVR] [--help] [--version] [who] [+ |-| =] [mode] File name

Example: Chmod-r 777/home/linux

For a detailed explanation of permissions, refer to: http://www.cnblogs.com/EasonJim/p/6525280.html

-C: If the file permissions have changed, the change action will be displayed
-F: Do not display an error message if the file permissions cannot be changed
-V: Show details of permission changes
-r: The same permissions change for all files in the current directory and subdirectories (that is, they are changed in a recursive manner)
--HELP: Show Auxiliary Instructions
--version: Display version

Action object who is either or a combination of the following letters: U means "user", that is, the owner of the file or directory.   G means "same group user", that is, all users who have the same group ID as the file owner.   O means "other (others) users". A means "all users". It is the system default value.
The action symbol can be: + Add a permission.   -Cancels a permission. = gives the given permission and cancels all other permissions, if any.
Setting the permissions represented by mode can be any combination of the following letters: R is readable. W writable.    x executable.   x append the x attribute only if the destination file is executable to some users, or if the target file is a directory. S is the owner of the file in which the owner or group ID of the process is placed when the file is executed.   The Way "U+s" sets the user ID bit of the file, "G+s" sets the group ID bit.   T save the program's text to the swap device.   You have the same permissions as the owner of the file.   G has the same permissions as a user with the same group as the file owner. o have the same permissions as other users.
File name: A list of files separated by spaces to change permissions, and wildcard characters are supported.

The difference and usage of chown and chmod in Linux

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.