About setfacl and getfacl

Source: Internet
Author: User
For details about setfacl and getfacl-Linux general technology-Linux technology and application, refer to the following. For setfacl and getfacl, I think I should have heard of some preliminary knowledge about the linux operating system. especially those who have knowledge of permissions should be more familiar with these two commands.
I am not very familiar with linux permission learning. I will share with you some of my experiences in the learning process based on the idea of learning and consulting, it is a rough outline for those new users who have no access permissions, or a shift in front of the hero.
In fact, the knowledge of permissions is really a lot, and there are countless commands related to it. I am afraid it is not so easy to get everything in a limited space. so today I only talk about two Common commands: setfacl and getfacl.
When we see the first response of this command, we should know that this is a pair of corresponding commands and there are ACLs. So, first, I have to explain the acl:
The full name of acl Access Control Lists is translated into a Chinese name "Access Control List". The permission Control of the traditional Linux file system is implemented through user, group, other, r (read), w (write) and different combinations of x (execution. With the development of applications, these permission combinations cannot meet the current complex file system permission control requirements. For example, the directory/data permission is drwxr-x ---, and the owner and group are both root. without changing the owner, the user tom is required to have full access to the Directory (rwx ). consider the following two methods (Here we assume that tom does not belong to the root group)
(1) Add the rwx permission to the/data other category. As tom is classified as the other category, he will also have the rwx permission.
(2) Add tom to the root group and assign the rwx permission to the root group. Then he will also have the rwx permission.
The above two methods are not suitable, so the traditional permission management settings are insufficient.
To solve these problems, Linux has developed a new file system permission management method called Access Control Lists (ACL ). To put it simply, ACL allows you to set the operation permissions of a specific user or user group on a file.
There are two types of ACLs. One is access ACL (access ACLs), which sets an access control list for files and directories. One is the default ACL (default ACLs), which can only be set for directories. If no ACL is set for a file in the directory, it uses the default ACL of the directory.
First, let me talk about getfacl (display the ACL of a file or directory)
In my computer, I first had a user named NEU, short for our school, and a user named software.

I operate on a neu user and create a file fileofneu under its directory.

We can see that its initial permission is-rw-r -- then I modify the permission for this file. the command used is chmod, and the modified File Permission is-rw-now the File Permission cannot be accessed by other users.

Switch to the sofeware user to verify the file's unavailability.

Next we will use the getfacl command to view the information. At this time, we have to go to the neu user to perform operations. The command format is very simple: getfacl fileofneu

The permission is clear at a glance. I will not introduce it much. I will use Setfacl to modify it so that it can only read and write to software users in other users' permissions.
Setfacl-m u: softeware: rw-fileofneu
Then, run the getfacl command to view the data. We can see that a user: software: rw is added, which indicates that the read and write permissions are open to the user software.
In order to verify its availability, switch to the software user to access the file and find that, unlike the previous one, the file can be read and written this time.
Let's talk about this one today. You can't remember it anymore.
By the way, I performed this operation just now and found that I couldn't get in. It turned out that I didn't give the software users the right to access the/home/neu directory. So, we have to apply the setfacl command to make the software user have the right to enter this directory. the operation is basically the same as above. please do it. If not, leave a message. I will start the kitchen later.









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.