macOS下 /etc/hosts 文件权限问题修复方案

文章目录

macOS下 etc/hosts 文件权限问题修复

前言

当在 macOS 上使用 vi编辑 /etc/hosts 文件时发现出现 Permission Denied 的提示,就算在前面加上 sudo 也照样出现一样的提示,解决方案如下;

解决方案

可以尝试使用如下命令尝试解除锁定;

shell 复制代码
sudo chflags nouchg /etc/hosts
sudo chflags noschg /etc/hosts
sudo chflags -hv noschg /etc/hosts
权限验证

可以使用如下命令进行验证权限;

shell 复制代码
 ls -l /etc/hosts
#验证修复的默认权限如下
# -rw-r--r--  1 root  wheel  214 Sep 21 07:58 /etc/hosts

经过以上的操作后发现 /etc/hosts 文件的权限已被修复,特此在此进行记录,希望可以帮助有需要的同学.

相关推荐
zandy10118 小时前
2026 主流技术栈:hermes agent多环境安装配置:Windows/Mac/Linux
linux·windows·macos
2501_916008899 小时前
Mac 上生成 AppStoreInfo.plist 文件,App Store 上架
android·macos·ios·小程序·uni-app·iphone·webview
猫头虎10 小时前
【Trea】Trea国内版|国际版|海外版下载|Mac版|Windows版|Linux下载配置教程
linux·人工智能·windows·macos·aigc·ai编程·agi
大可ai中文版镜像10 小时前
OpenAI Codex Desktop App 保姆级安装教程(Windows / Mac)
人工智能·macos·codex
文滨10 小时前
10分钟搞定!Mac 配置 GitHub SSH 完全指南(小白也能看懂)
前端·macos·ssh·github
明月(Alioo)11 小时前
macOS 上 Charles 代理 HTTPS 抓包失败问题完整解决方案
网络协议·macos·https
Rudon滨海渔村12 小时前
Mac录屏教程:只需要内录电脑声音,不需要麦克风声音
macos·免费·录屏·blackhole
00后程序员张1 天前
Windows 下怎么生成 AppStoreInfo.plist?不依赖 Xcode 的方法
ide·macos·ios·小程序·uni-app·iphone·xcode
boldiy1 天前
如何在MAC电脑中实现自动切换windows快捷键
windows·macos
张3蜂1 天前
Flutter macOS 安装文档
flutter·macos