Linux chmod commands modify file and folder permissions method

Source: Internet
Author: User
Tags chmod readable file permissions

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

The meanings of the options in the command are

U represents "User", which is the owner of a file or directory.
G means "same group of users", that is, all users who have the same group ID as the owner of the file.
O Represents "other (others) users".
A represents "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.
The permissions represented by mode set can be any combination of the following letters:
R readable.
W can be written.
X executable.
x attributes are appended only if the target file is executable for some users or if the destination file is a directory.
s the owner or group ID of the process to the file owner of the file when the file is executed. Mode "U+s" sets the user ID bit of the file, and "G+s" sets the group ID bit.
T saves the text of the program to the switching device.
You have the same permissions as the owner of the file.
G has the same permissions as the user of the same group as the file owner.
o have the same permissions as other users.

Instance

Ways to modify a file's read-write properties
For example: Modify the index.html file to write-readable executable:

The code is as follows Copy Code
chmod 777 Index.html

To modify all file attributes under the directory to write-readable executable:

The code is as follows Copy Code
chmod 777 *.*

You can replace the folder name with the suffix name.
For example: Modify the properties of all HTM files:

The code is as follows Copy Code
chmod 777 *.htm

Ways to modify folder properties
Modify the directory/images/xiao to writable and readable executable

The code is as follows Copy Code
chmod 777/images/xiao

Modify all folder properties under the directory

The code is as follows Copy Code
chmod 777 *

Replace the folder name with *.

To modify all files and folders and subfolder properties within a folder to be writable and read executable

The code is as follows Copy Code

Chmod-r 777/upload


Summary Linux directory and file permissions difference

Files: Read file contents (r), write data to File (w), execute file As command (x).
Table of Contents: Read the file name (R) contained in the directory, write information to the directory (add and delete links to index points), search directories (can use the directory name as the pathname to access the files and subdirectories it contains)
Specifically, this is:
(1) A user with read-only access cannot enter the directory with a CD: It must also have Execute permission to enter.
(2) Users who have Execute permissions can access files in the directory only if they know the file name and have read rights.
(3) must have read and execute permissions to the LS list, or use the CD command to enter the directory.
(4) Write permission to a directory, you can create, delete, or modify any file or subdirectory under the directory, even if the file or subdirectory belongs to another user.

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.