How to use ACL to back up and restore file permissions under Linux
Editor to share with you how to use ACL backup and restore file permissions under Linux, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
The full name of ACL is Access Control List (access Control list), an access control list for files / directories. It provides an additional and more flexible rights management mechanism for the file system on the basis of UGO rights management. It is designed as a supplement to UNIX file rights management. ACL allows you to set access to any file / directory to any user or group.
1. Install ACL tools
On Debian, Ubuntu,Linux Mint
$sudo apt-get install acl
On CentOS,Fedora,RHEL
$sudo yum install acl2. The permission to back up all files under the current directory (including subdirectories) [root@linuxprobe tmp] # ls-ltotal 8 RWXR Murray. 1 root root 0 Mar 3 04:40 install.txt-rwxr-xr-x. 1 root root 0 Mar 3 04:41 linuxprobe.txt [root@linuxprobe tmp] # getfacl-R. > permissions.txt...
This command writes all the ACL information for all files into a file named permissions.txt.
The following is some directory information in the generated permissions.txt file
[root@linuxprobe tmp] # cat permissions.txt# file:. # owner: root# group: root# flags:-- tuser::rwxgroup::rwxother::rwx# file: install.txt# owner: root# group: rootuser::rwxgroup::r--other::r--# file: linuxprobe.txt# owner: root# group: rootuser::rwxgroup::r-xother::r-x# file: permissions.txt# owner: root# group: rootuser::rw-group::r--other::r--...3. Modify a file permission, such as: modify linuxprobe.txt and install.txt permissions [root@linuxprobe tmp] # chmod 733 linuxprobe.txt [root@linuxprobe tmp] # chmod 573 install.txt [root@linuxprobe tmp] # ls-ltotal 8-r-xrwx-wx. 1 root root 0 Mar 3 04:40 install.txt-rwx-wx-wx. 1 root root 0 Mar 3 04:41 linuxprobe.txt-rw-r--r--. 1 root root 4361 Mar 3 04:41 permissions.txt.4. Restore the original authority
1) cd to the directory where the permissions.txt was created 2) execute the following command:
Setfacl-restore=permissions.txt
You can see that linuxprobe.txt and install.txt permissions have been restored.
[root@linuxprobe tmp] # setfacl-- restore=permissions.txt [root@linuxprobe tmp] # ls-ltotal 8 Murray RWXR Murray. 1 root root 0 Mar 3 04:40 install.txt-rwxr-xr-x. 1 root root 0 Mar 3 04:41 linuxprobe.txt-rw-r--r--. 1 root root 4361 Mar 3 04:41 permissions.txt. These are all the contents of this article entitled "how to use ACL backup and restore File permissions under Linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!