Linux View and modify file permissions and related

Source: Internet
Author: User

Linux View and modify file permissions and related to view file permissions: In Terminal input: Ls-l xxx.xxx (xxx.xxx is the file name) then there will be similar information, mainly these:-rw-rw-r--there is a total of 10 digits: The first one-represents the type The middle that three rw-is represented by the owner (user) and then that three rw-represents the group (group) finally that three r--represents the other person (other) and then I'll explain the back 9 digits: R indicates that the file can be read (re AD) W means that the file can be written (write) x indicating that the file can be executed (if it is a program)-indicating that the corresponding permission has not been granted right now it's time to say modify file permissions in Terminal input: chmod o+w xxx.xxx means to give someone else to write xxx.xxx this file The permission chmod go-rw xxx.xxx means to delete the read and write permissions of the group and others in xxx.xxx where: U represents the owner (user) G for the owner's group (groups) O on behalf of others, but not u and G (Other) A For all people, also   is to include U,g and O r to indicate that the 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 use numbers instead of R------------4 W-----------2    X------------1-------------0 Action: + means add permission-means delete permission = means to make it the only permission when everyone understands 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 others have only 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 permission to read and write-rwxrwxrwx (777) Everyone has access to read and write and execute

Linux files have four access rights: Readable (R), writable (W), executable (x), and no permissions (-).
Enter the LS-L command in the terminal to view the permissions of a file or directory under the current directory, and to display the first field of data for each row is its permission content. The first field consists of 10 characters, such as:
-rwxr-xr-x
The first bit represents the file type,-represents the file, D represents the directory, and each subsequent three-bit character represents the permissions that three different groups of users have.
2-4-bit represents the permissions of the file owner, that is, U (USESR) permissions
5-7-bit represents the permissions of the group member to which the file owner belongs, G (Group) permission
8-10-bit represents permissions for users other than the group to which the owner belongs, O (Others) permissions
The sum of 2-10-bit permissions is sometimes called a (all) permission
The above field indicates that this is a file (not a directory) and that the file owner has read, write, and execute permissions.
The owner-owned group member and a user other than the owning group have read and Execute permissions without write permission.
R, W and X can also be represented by 4, 2, or 0, which is more convenient when modifying permissions.
Modify file permissions under Linux with the chmod command.
There are two uses of the chmod command. One is an expression that contains letters and operators, that is, the text setting method, and the other is a digital setting method that contains numbers.
1. Text Setting method
chmod [who] [+ | - | =] [mode] 文件名
Where the Who can be any of the above mentioned U, G, O, a or their combination. operator + 、-、 = Adds a permission, cancels a permission, assigns a given permission, and cancels all other permissions (if any), respectively.
The mood is any combination of R, W, X.
For example:
chmod g+r,o+r fileName
Represents the addition of Read permissions to the file filename to the same group and other users.
2. The digital setting rule is relatively simple
chmod [mode] 文件名
Regardless of what permissions to add, but can directly set what permissions, where the mood is a three-digit number, each digit can be any one of 1 to 7, representing a corresponding user type of permissions, such as:
chmod 777 FileName
This means that all users have all the permissions of filename, which is a very dangerous thing to do. To modify permissions in Linux, use Administrator privileges, such as using sudo in Ubuntu or switching to the root account.
Chmod can also be followed with parameters, mainly with-R (to modify the directory to use)-V (Display operation).
Such as:
chmod -R 755 dirName
Change the permissions of all files and directories under DirName to 755, which is a recursive operation on the directory.

Linux View and modify file permissions and related

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.