有时你需要在一些root级别的目录下创建和删除文件,如果你没有切换到root用户下,系统会提示你没有权限,如下所示:
liaowenxiongdeMacBook-Air:local liaowenxiong$ mkdir test
mkdir: test: Permission denied
liaowenxiongdeMacBook-Air:local liaowenxiong$
普通用户切换到root用户,命令语句如下:
liaowenxiongdeMacBook-Air:~ liaowenxiong$ sudo -i // 横杠和字母i之间不允许有空格The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.
liaowenxiongdeMacBook-Air:~ root#
root用户切换到普通用户,命令语句如下:
liaowenxiongdeMacBook-Air:~ root# su - liaowenxiong // 横杠和用户名之间必须有空格The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.
liaowenxiongdeMacBook-Air:~ liaowenxiong$