Backup and recovery of file permissions for Linux systems

Source: Internet
Author: User

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

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.