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 prevent the modification of some important files in Linux

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article is to share with you about how to prevent the modification of some important documents in Linux, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.

In the process of managing the Linux system, we often do not want users to modify some important key files, configuration files and important personal data at will. At this time, we need to protect the file from tampering with the file.

Permission protection is set to 600 permissions

For example:

[root@localhost /] # chmod 600 / usr/local/webserver/nginx/conf/nginx.conf

So we set the / usr/local/webserver/nginx/conf/nginx.conf file to 600 permissions to prevent modification.

Use the "chattr" command

Alternatively, if Linux is using an ext2, ext3, or ext4 file system, you can also use the "chattr" command:

The code is as follows:

Usage: chattr [- RVf] [- + = AacDdeijsSu] [- v version] files...

Use the I attribute

Add an I attribute to important files, and even root users cannot directly modify or delete such files to effectively prevent accidental modification or deletion of files. The specific commands are as follows:

The code is as follows:

# chattr + I passwd

Add an I attribute to the passwd file

Remove the I attribute using the following command:

The code is as follows:

# chattr-I passwd

Remove the attribute of the passwd file I and modify the file.

The above is how to prevent the modification of some important documents in Linux. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

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