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

Solution to the problem of "unable to open and write file" under Centos system

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

Share

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

Abstract

Recently in the work of the release limit a problem, currently a root user, to edit / etc/ssh/sshd_config but do not have permission to modify. Error such as "/ etc/ssh/sshd_config" E212: unable to open and write to the file.

Problem thinking

Since the prompt does not have permissions, and it is a root user, you must have set special permissions for this file. Check the special permission settings:

Getfacllsattr

Getfacl results are normal.

Root@pts/1$ getfacl / etc/ssh/sshd_configgetfacl: Removing leading'/ 'from absolute path names# file: etc/ssh/sshd_config# owner: root# group: rootuser::rw-group::---other::

Lsattr prompts error:-bash: lsattr: command not found does not have this command, strange. The current system is CentOS release 6.5 (Final), so try to install it.

Find out that lsattr and chattr belong to the installation package e2fsprogs, install it.

Root@pts/1$ yum install e2fsprogs setup installation process to resolve dependencies-- > perform transaction checks-- > Package e2fsprogs.x86_64 0VOR 1.41.12-18.el6_5.1 will be upgrade-- > Package e2fsprogs.x86_64 0Rom 1.41.12-23.el6 will be an update-- > handle dependencies libss = 1.41.12-23.el6 It is required by the software package e2fsprogs-1.41.12-23.el6.x86_64. Update completed: e2fsprogs.x86_64 023.el6 libcom_err.x86_64 1.41.12-23.el6 is upgraded as a dependency: e2fsprogs-libs.x86_64 0v 1.41.12-23.el6 libcom_err.x86_64 0v 1.41.12-23.el6 libcom_err-devel.x86_64 0v 1.41.12-23.el6 libss.x86_64 0v 1.41.12-23.el6

Over!

Lsattr check

Root@pts/1$ lsattr / etc/ssh/sshd_config----i-e- / etc/ssh/sshd_config

Here I stands for immutable, and we cannot change, rename, or delete the file when this property is enabled on the file.

The e here stands for extent format, which indicates that the file uses a mapping extension of blocks on disk. Belong to the "normal" rule

Chattr deletes an unmodifiable attribute

Root@pts/1$ chattr-I / etc/ssh/sshd_configiZ25zjpz5pqZ [~] 2017-12-16 10:59:14root@pts/1$ lsattr / etc/ssh/sshd_config-e- / etc/ssh/sshd_configiZ25zjpz5pqZ [~] 2017-12-16 10:59:17root@pts/1$ vim / etc/ssh/sshd_configiZ25zjpz5pqZ [~] 2017-12-16 10:59:26root@pts/1 $

You can see from the above that we can modify the file successfully after we cancel the I setting.

If you have completed the modification, you can restore the unmodifiable properties, you can execute chattr + I / etc/ssh/sshd_config

Summary

The above is the whole content of this article, I hope that the content of this article has a certain reference and learning value for your study or work, if you have any questions, you can leave a message and exchange, 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