在 macOS 中手动指定 host(DNS Spoofing)
macOS 的默认登录用户不是 root, 所以不具备最高系统权限, 是无法修改系统保护资源的.
root 用户
macOS 中, 有且仅有一个 root 用户, uid 为0.
$ dscacheutil -q user -a name root
name: root
password: *
uid: 0
gid: 0
dir: /var/root
shell: /bin/sh
gecos: System Administrator
sudo 命令
root 具有最高权限,可以做任何事情. sudo命令可以切换为 root 用户.
- 默认登陆用户无法修改
/etc/hosts
文件
$ whoami
foo
$ vi /etc/hosts
'readonly' option is set for "/private/etc/hosts".
Do you wish to write anyway?
"/private/etc/hosts"
"/private/etc/hosts" E212: Can't open file for writing
- 切换为 root 身份, 可以修改任何资源文件
$ sudo vi /etc/hosts
Password: