Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report