In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
This article is to share with you what Linux file permissions have. The editor thought it was very practical, so I shared it with you as a reference. Let's follow the editor and have a look.
Users and user groups
Linux file permissions is a concept that is closely related to users and user groups. For a file, users can be divided into three categories:
Owner of the file-user
Other members of the user group of the owner of the file-group
Users other than the owner and user group members-others
File permissions are relative to these three types of users, and users with different identities can have different permissions.
File attribute
Use the command ls-l to get the details of the file, such as:
Drwxr-xr-x 5 root root 4096 Sep 7 19:52 dotemacsdrwxr-xr-x 6 root root 4096 Sep 3 22:34 dotfilesdrwxr-xr-x 9 root root 4096 Sep 11 10:19 emacs-kit
We can divide each piece of information into eight parts. For example, the first piece of information above can be divided into:
Number of file type permission information links owner user group file capacity modification date file name drwxr-xr-x5rootroot4096Sep 7 19:52dotemacs
Here mainly understand the file type and permission information, interested in other parts can be their own Google.
File type
Files in Linux can be divided into five types, and the first character in each piece of information output by ls-l is used to indicate the file type.
Each file type and its characters are represented as:
Represents the character file type d directory-file l symbolic links and other b storage interface devices c serial port devices, such as keyboard, mouse and other permission information
Through the concept of users and user groups, we can know that permissions are relative to three types of users, so the permission information displayed by ls-l is also divided into three groups.
The permission information of each file consists of 9 characters and is divided into three groups, corresponding to the permissions of the owner, the user group, and others.
For the permission information rwxr-xr-x, the owner's permission is rwx, and the permissions of user groups and others are RMIX. com.
Each group of permissions is divided into read permission, write permission and execution permission, which are represented by the characters r, w and x, respectively. If you do not have the appropriate permissions, use the character-representation.
Therefore, the permission information rwxr-xr-x can be understood as: the owner has read, write and execute permissions, while user groups and others only have read and execute permissions.
Modify file owner and user group
The commands chown and chgrp can be used to modify file owners and user groups, and are easy to use:
# modify file owner $chown [- R] account name file or directory $chown [- R] account name: group name file or directory # modify the user group to which the file belongs $chgrp [- R] user group name file or directory
The parameter-R changes recursively, that is, all files in the subdirectory are changed.
Modify file permissions
The command chmod is used to modify the permissions of a file and provides two ways to modify file permissions.
Numeric type changes file permissions
We can use numbers to represent each permission, and the corresponding numbers for each permission are:
R:4w:2x:1
The three permission scores for each identity need to be accumulated. For example, when the permission is rwxrwx---, the corresponding score is:
User = rwx = 4 "2" 1 = 7group = rwx = 4 "2" 1 = 7others =-= 0 "0" 0
The number of file permissions obtained is 770, which can be used to modify permissions:
$chmod [- R] 770 file or directory
Obviously, it is troublesome to modify file permissions in this way, so chmod provides another better way to modify file permissions.
Symbol type changes file permissions
To change the file permission of symbol type, you need to follow certain syntax rules, such as identity representation, operation representation and permission representation.
Identity identifier:
The identity represented by the signer u file owner g file owner user group o other people an all users
Operation representation:
Operation represented by signifier + add permission-remove permission = set permission
The permission representations are r, w and x.
From the composition of the token, you can probably guess how to modify the file permissions. For example, the following directive gives the owner all permissions and adds execution permissions to user groups and others:
Chmod uprirwx.vimrc
It is important to note that there is no space between uprirwx.goggx.
The role of permissions
The same permission has a different meaning for files and directories. Let's take a look at it here.
Permission file directory r can read file contents can read directory structure list w can edit and modify file contents can change directory structure list x can be executed by the system the user can enter the directory (cd)
One permission to note here is that you can change the directory structure list, which means you can:
Create new files and directories
Delete existing files and directories
Rename an existing file or directory
Move the files and directory locations in this directory
Therefore, the permission of w should be used cautiously.
Thank you for reading! What about the Linux file permissions to share here, I hope the above content can be of some help to you, so that you can learn more knowledge. If you think the article is good, you can share it and let more people see it.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.