Chattr-i/etc/hosts #hosts文件去掉禁止随意更改的功能, try a few more times. Then VI go in to modify the file.
Similarly, chattr +i/etc/hosts #为hosts文件添加防止修改的权限
-------------------------------------------------------------
Chattr (change attribute)
Feature Description: Change file properties.
Syntax: chattr [-rv][-v< version number >][+/-/=< properties >][file or directory ...]
Additional note: This directive alters the file or directory attributes stored on the ext2 file system, which have the following 8 modes:
A: Make the file or directory available for additional use only.
B: Do not update the last access time of the file or directory.
C: Compress the file or directory and store it.
D: Exclude files or directories from dumping operations.
I: Do not alter the file or directory arbitrarily.
S: Privacy delete files or directories.
S: Update files or directories instantly.
U: Remove outside of prevention.
Parameters
-R recursively handles all files and subdirectories under the specified directory.
-v< version number > set file or directory version.
-V Displays the instruction execution process.
+< Properties > Open the Item property of the file or directory.
-< Properties > Close the Item property of the file or directory.
The =< property > Specifies the Item property of the file or directory.
This article is from the "System Operations" blog, please be sure to keep this source http://gravel.blog.51cto.com/6432642/1657972
Linux Edit File ReadOnly Read only