Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to set the permissions of backup and restore files in Linux system

Shulou Source: shulou.com Published: 2022-06-01 17:25:44 10月18日 Update

Today, I will talk to you about how to set up backup and restore file permissions in the Linux system. Many people may not know much about it. In order to make you understand better, the editor has summarized the following contents for you. I hope you can get something according to this article.

1. Install ACL tools

On Debian, Ubuntu,Linux Mint

The code is as follows:

$sudo apt-get install acl

On CentOS,Fedora,RHEL

The code is as follows:

$sudo yum install acl

two。 Permission to back up all files in the current directory (including subdirectories)

The code is as follows:

[root@linuxprobe tmp] # ls-l

Total 8

-rwxr--r--. 1 root root 0 Mar 3 04:40 install.txt

-rwxr-xr-x. 1 root root 0 Mar 3 04:41 linuxprobe.txt

The code is as follows:

[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

The code is as follows:

[root@linuxprobe tmp] # cat permissions.txt

# file:.

# owner: root

# group: root

# flags:-t

User::rwx

Group::rwx

Other::rwx

# file: install.txt

# owner: root

# group: root

User::rwx

Group::r--

Other::r--

# file: linuxprobe.txt

# owner: root

# group: root

User::rwx

Group::r-x

Other::r-x

# file: permissions.txt

# owner: root

# group: root

User::rw-

Group::r--

Other::r--

...

3. Modify a file's permissions, such as linuxprobe.txt and install.txt permissions

The code is as follows:

[root@linuxprobe tmp] # chmod 733 linuxprobe.txt

[root@linuxprobe tmp] # chmod 573 install.txt

[root@linuxprobe tmp] # ls-l

Total 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:

The code is as follows:

Setfacl-restore=permissions.txt

You can see that linuxprobe.txt and install.txt permissions have been restored.

The code is as follows:

[root@linuxprobe tmp] # setfacl-- restore=permissions.txt

[root@linuxprobe tmp] # ls-l

Total 8

-rwxr--r--. 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

.

After reading the above, do you have any further understanding of how to set backup and restore file permissions in the Linux system? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Tags: Files permissions code backups contents directories systems previous generations information commands subdirectories tools locations more knowledge articles industries information information channels Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Shulou Information NVidia Docker Microsoft