Linux chmod command to modify file and folder permissions attached to an instance

Source: Internet
Author: User
Tags readable


Linux chmod command to modify file and folder permissions attached to an instance

chmod directory

Lost name body: [Increase decrease] Source: Internet time: 05-01 20:46:07 I want to comment.


In Linux to modify the permissions of a folder or file we need to use the Linux chmod command to do, below I wrote a few simple examples you can refer to


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

chmod all files in directory 


The meaning of each option in the command is



U means "user", which 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.chmod recursive directory 
O means "other (others) users".
A means "all users". It is the system default value.
The operation symbols can be:chmod cannot access gradlew no such file or directory
+ Add a permission.
-Cancels a permission.
= gives the given permission and cancels all other permissions, chmod 777 directory if any.
Setting the permissions represented by mode can be any combination of the following letters:chmod directory permissions
R is readable.
W writable.
X executable.
x append the x attribute only if the destination file is executable to some users,chmod files in directory  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.



Instance



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


Copy CodeThe code is as follows:
chmod 777 Index.html





To modify all the file properties under the directory writable readable executable:


Copy CodeThe code is as follows:
chmod 777 * *





Replace the folder name with the suffix name *.
For example: Modify the properties of all HTM files:





Copy CodeThe code is as follows:
chmod 777 *.htm





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





Copy CodeThe code is as follows:
chmod 777/images/xiao





Modify all folder properties under the directory





Copy CodeThe code is as follows:
chmod 777 *





Replace the folder name with a *.



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





Copy CodeThe code is as follows:
Chmod-r 777/upload





Summarize the permissions differences for directories and files under Linux


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

View Directory Permissions

To view file permission statements:
In Terminal input:
Ls-l xxx.xxx (xxx.xxx is the file name)
Then there will be similar messages, mostly these:
-rw-rw-r--
A total of 10 digits
Which: the front one-represents the type
The middle three rw-represents the owner (user)
Then those three rw-represent groups (group)
The last three r--represent others (other).
And then I'll explain the 9 digits in the back:
R indicates that a file can be read (read)
W indicates that the file can be written (write)
x indicates that the file can be executed (if it is a program)
-Indicates that the appropriate permission has not been granted
Now it's time to talk about modifying file permissions.
In Terminal input:
chmod o W xxx.xxx
Give other people permission to write xxx.xxx this file
chmod GO-RW xxx.xxx
Represents the deletion of read and write permissions for groups and others in xxx.xxx
which
U on behalf of owner (user)
G represents the group where the owner resides
O stands for others, but not u and g (other).
A represents all people, including U,g and O.
R indicates that a file can be read (read)
W indicates that the file can be written (write)
x indicates that the file can be executed (if it is a program)
Where: Rwx can also be replaced by numbers
R------------4
W-----------2
X------------1
-------------0
Let's go:
Represents the Add permission
-Indicates delete permission
= indicates a permission to make it unique
When we all understand the above, then we often have some of the following permissions are easy to understand:
-RW-------(600) Only the owner has read and write permissions
-rw-r--r--(644) Only the owner has read and write permissions, and the group and other people only have Read permissions
-RWX------(700) Only the owner has read, write, execute permissions
-rwxr-xr-x (755) Only the owner has read, write, execute permissions, groups and other people only read and Execute permissions
-rwx--x--x (711) Only the owner has read, write, execute permissions, groups and other people only execute the permissions
-rw-rw-rw-(666) Everyone has access to read and write
-RWXRWXRWX (777) Everyone has access to read and write and execute


Linux chmod command to modify file and folder permissions attached to an instance


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.