Mac下 对readonly类型文件或者目录操作方法

mac 环境对readonly类型文件修改、目录下创建文件正常操作都会失败,如下:

vim /etc/hosts

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1       localhost
255.255.255.255 broadcasthost
::1             localhost
# 100.81.197.201 hsp.aliyun-inc.com
11.164.61.51 hsp.aliyun-inc.com
# Added by Docker Desktop
# To allow the same kube context to work on the host and the container:
127.0.0.1 kubernetes.docker.internal
# End of section
~                                                                                                                                                                                                                                          
                                                                                                                                                                                                                                      
-- INSERT -- W10: Warning: Changing a readonly file


# 使用 wq! 依旧无法保存

# 使用sudo ,输入密码成功修改
sudo vim /etc/hosts
Password:

上述方法适用于mac os monterey(12.0.1)之后

12.0.1之前需要修改csrutil status 状态

1、重启mac,按住Command+R,等到系统进入安全模式。

2、选择一个账户,然后点击屏幕上方的工具栏找到命令行工具。

3、执行,命令 csrutil disable

4、重启电脑后,进入正常模式进行操作

参考文档:

1、https://www.jianshu.com/p/c5e2b29a7c19

2、https://blog.csdn.net/qq_40816795/article/details/123189262

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值