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

Key files of chattr and lsattr management system

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

Share

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

In the system of the server, there are many key files that are not allowed to be modified to prevent other users or people from modifying key files, but in the actual production environment, many managers often do not pay attention to this, which leads to the possibility that the system files will be changed, so we need to lock the key files and lock the key files in the system. Of course, there are important files that cannot be modified to be locked.

[root@test test] # chattr + I / etc/passwd# user key information file [root@test test] # chattr + I / etc/shadow# user shadow file, store the user's ciphertext password [root@test test] # chattr + I / etc/gshadow# group shadow file [root@test test] # chattr + I / etc/group# group file [root@test test] # chattr + I / etc/services# system default port file

Even root users cannot delete and modify files after locking. The usage parameters and modes of chattr are as follows:

This directive alters the attributes of a file or directory stored on the ext2 file system in the following eight modes: a: make the file or directory for additional purposes only. B: the last access time of the file or directory is not updated. C: compress the file or directory and store it. D: exclude files or directories from the dump operation. I: files or directories shall not be changed arbitrarily. S: delete files or directories in secret. S: update files or directories immediately. U: delete outside of prevention. Parameter:-R recursive processing, all files and subdirectories under the specified directory will be processed together. -v sets the file or directory version. -V displays the instruction execution process. + Open this property of the file or directory. -turn off this property of the file or directory. = specifies the property of the file or directory.

But what if you sometimes have to add new users, or why some files with permissions cannot be modified?

[root@test test] # useradd test1useradd: unable to open password file

We can take a look at the hidden properties of the / etc/passwd file with lsattr. Files like this are locked files.

[root@test test] # lsattr / etc/passwd----i- / etc/passwd

Specific parameters for llattr usage:

-a displays all files and directories, including "." Additional built-in for the first character of the name, the current directory. With the upper directory "..". -d displays the directory name, not its contents. -l this parameter currently has no effect. -R recursive processing, all files and subdirectories under the specified directory are processed together. -v displays the file or directory version. -V displays version information.

So if you need to modify that file, you need to modify the hidden properties of the file.

[root@test test] # chattr-I / etc/passwd

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

Network Security

Wechat

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

12
Report