我需要运行具有管理权限的命令。有人说我应该以 root 身份运行命令。我该怎么做呢?
我将此行添加到visudo,以便向 yael 用户授予完全权限:
yael ALL=(ALL) NOPASSWD: ALL
Run Code Online (Sandbox Code Playgroud)
但是当我想更新/etc/hosts文件时,我的权限被拒绝:
su – yael
echo "10.10.10.10 yael_host">>/etc/hosts
-bash: /etc/hosts: Permission denied
sudo echo "10.10.10.10 yael_host">>/etc/hosts
-bash: /etc/hosts: Permission denied
ls -ltr /etc/hosts
-rw-r--r--. 1 root root 185 Aug 7 09:29 /etc/hosts
Run Code Online (Sandbox Code Playgroud)
我怎样才能像 root 一样给予用户 yael 能力?