Objective
Recent work encountered the need for multiple accounts at the same time need to read and write access to a file, first try to use the chmod 3 permissions to set, after the predecessor pointed out that the use of FACL settings, access to data, a rough record of the experimental results as shown in this chapter, if there are omissions and errors, please crossing point out, thank you.
Lab Environment:
Linux distribution:
[Email protected] ~]# cat/etc/redhat-release
Red Hat Enterprise Linux Server Release 6.2 (Santiago)
Version number of the SETFACL:
[Email protected] ~]# setfacl-version
Setfacl 2.2.49
Experimental Purpose:
User A and B have both R permissions on the Test.txt.
Experimental process record:
1. New User A and b,a and B same user group test, create a new Text.txt file, and authorize User A
[email protected] ~]# groups A
A:test
[email protected] ~]# groups B
B:test
2. View the ACL properties of the current Text.txt file:
[Email protected] ~]# Getfacl/home/test.txt
Getfacl:removing leading '/' from absolute path names
# File:home/test.txt
# owner:a
# Group:test
user::r--
Group::---
Mask::---
Other::---
3, directly with chmod
Because User A and B belong to group text, the file Test.txt belongs to User A, so you can set the group to have R permission directly, but the disadvantage is that the other users in group test also have permissions.
[Email protected] ~]# Getfacl/home/test.txt
Getfacl:removing leading '/' from absolute path names
# File:home/test.txt
# owner:a
# Group:test
User::rwx
group::r--
Other::---
User B can now access the Test.txt:
[Email protected] ~]$ Cat/home/test.txt
Hello world!
4. Set file ACLs using Setfacl
First chmod 700/home/test.txt to restore the file ACL and then experiment again:
[Email protected] ~]# setfacl-m u:b:r/home/test.txt
[Email protected] ~]# Getfacl/home/test.txt
Getfacl:removing leading '/' from absolute path names
# File:home/test.txt
# owner:a
# Group:test
User::rwx
user:b:r--
Group::---
mask::r--
Other::---
User B can access the Test.txt file at this time.
5. Instructions Supplementary Instructions
setfacl-m u:b:r/home/test.txt; instruction format such as left,-M followed by u:b:r (User: User name: Permissions), where if you want to set group permissions, you can change to g;r if you need all the permissions can be directly: rwx.
Experiment Summary:
This experiment deepened the understanding of the Facl setting and understood that the SETFACL can be flexibly set up with file ACLs without having to set up user group classifications too much.
Setfacl and Getfacl of Linux file ACLs