从一个案例来看chattr命令的神奇之处
<div style="color: black; text-align: left; margin-bottom: 10px;">
<h1 style="color: black; text-align: left; margin-bottom: 10px;">概述</h1>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">在Linux系统中,<span style="color: black;">持有</span>最高权限的用户root,在执行文件权限的修改,<span style="color: black;">或</span>修改文件时<span style="color: black;">亦</span>会<span style="color: black;">显现</span>如下错误:</p>1. chmod: changing permissions of xxx: Operation not permitted;
2. E45: readonly option is set (add ! to override)<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">接下来用<span style="color: black;">近期</span>碰到的一个案例来介绍<span style="color: black;">怎样</span><span style="color: black;">处理</span>root用户无权限修改文件的问题。</p>
<h1 style="color: black; text-align: left; margin-bottom: 10px;">1、<span style="color: black;">没法</span>删除应用?</h1>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">因为</span>项目迁移,<span style="color: black;">因此</span>需要删掉之前的文件,<span style="color: black;">而后</span>就<span style="color: black;">发掘</span>了个很奇怪的现象,用root居然删不掉?提示权限拒绝。</p>
<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/pgc-image/0a5881b0e1714a37be4d5e4ddadf6a0d~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1724866089&x-signature=jZkcqFw4Dx5gApf2%2FJ%2F4iWVXhDc%3D" style="width: 50%; margin-bottom: 20px;"></div>
<h1 style="color: black; text-align: left; margin-bottom: 10px;">2、授权测试</h1>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">想着授权777再删一下<span style="color: black;">瞧瞧</span>,<span style="color: black;">发掘</span>授权<span style="color: black;">亦</span>是不允许的</p>
<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/pgc-image/2e962f46c0994bd8b193c0214fdfa243~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1724866089&x-signature=ZV5K%2FDR2K0uok42hBpIq4dDMRF0%3D" style="width: 50%; margin-bottom: 20px;"></div>
<h1 style="color: black; text-align: left; margin-bottom: 10px;">3、lsattr查看文件属性</h1>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">执行的chmod命令,其底层实现是chattr命令,这个命令<span style="color: black;">乃至</span><span style="color: black;">能够</span>锁定文件,即使root用户<span style="color: black;">亦</span>操作不了此文件。<span style="color: black;">因此</span><span style="color: black;">此时</span>候在<span style="color: black;">思虑</span>是不是chattr影响了,<span style="color: black;">然则</span>在用lsattr查看文件的属性时<span style="color: black;">发掘</span>并<span style="color: black;">无</span>i属性(有i属性的文件是<span style="color: black;">不可</span>修改的,更不可被删除,即使是root用户<span style="color: black;">亦</span>不可),<span style="color: black;">这儿</span>给了我一个误区,<span style="color: black;">因此</span>就没测试chattr了</p>
<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/pgc-image/428917a3c4124e15a95302c243e6f9fe~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1724866089&x-signature=iVjBrK816g%2Bt%2F5iXDiSydZgvhcM%3D" style="width: 50%; margin-bottom: 20px;"></div>
<h1 style="color: black; text-align: left; margin-bottom: 10px;">4、chattr命令</h1>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">去除i属性:chattr -i webapps/,重新测试<span style="color: black;">发掘</span>OK了</p>
<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/pgc-image/7d4f3cf4335646db8ec7f3e85a5cadf1~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1724866089&x-signature=2w%2FIzZ3Su0xZF8psd0xcSdn8qB4%3D" style="width: 50%; margin-bottom: 20px;"></div>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">觉得有用的<span style="color: black;">伴侣</span>多帮忙转发哦!后面会分享<span style="color: black;">更加多</span>devops和DBA方面的内容,感兴趣的<span style="color: black;">伴侣</span><span style="color: black;">能够</span>关注下~</p>
<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/pgc-image/fd11aef18c17485391452c68fcdba8ce~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1724866089&x-signature=giaVUn2WFaafTjMBYAGTLdr%2Bo7o%3D" style="width: 50%; margin-bottom: 20px;"></div>
</div>
期待楼主的下一次分享!” 你的话语如春风拂面,温暖了我的心房,真的很感谢。 感谢您的精彩评论,为我带来了新的思考角度。 期待你更多的精彩评论,一起交流学习。
页:
[1]