have been thinking about a problem recently, if hand shake accidentally execute command chmod 777-r/, just no system backup, it is really tragic. The backup of production system is really the most heavy.
This session only discusses how to back up system file permissions.
1. Create a file for testing.
[email protected] ~]# ll testfacl.txt-rw-r--r--1 root root 0 Mar 05:27 testfacl.txt
You can see that the Testfacl.txt file permission is 644.
2. Backup permissions for all files under the current directory (including subdirectories)
[Email protected] ~]# getfacl-r. >/tmp/facl.bak[[email protected] ~]# grep "Testfacl.txt"-A 5/tmp/facl.bak # file:testfacl.txt# owner:root# Group: rootuser::rw-group::r--other::r--
3. Modify File Permissions
[Email protected] ~]# chmod 777 Testfacl.txt; ll testfacl.txt-rwxrwxrwx 1 root root 0 Mar 05:27 testfacl.txt
4. Restore File Permissions
[Email protected] ~]# setfacl--restore=/tmp/facl.bak [[email protected] ~]# ll testfacl.txt-rw-r--r--1 root root 0 Mar 05:27 Testfacl.txt
As you can see, the permissions for the previous backup have been restored.
In case of prevention, it is best to give each system a file permission to back up, or not to cry without tears.
Getfacl-r/>/tmp/a.facl
This article is from "[[email protected] Prof. Open ~] #rm-rf/" blog, please be sure to keep this source http://luweikai.blog.51cto.com/1705672/1751707
Backup and recovery of file permissions for Linux systems