I add this line to visudo
, in order to give full permissions to yael user:
yael ALL=(ALL) NOPASSWD: ALL
But when I want to update the /etc/hosts
file, I get permission denied:
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
How can I give to user yael ability like root?
The source of the problem is that the output redirection is done by the shell (user yael) and not by sudo echo
.
In order to enforce that the writing to /etc/hosts
will be done by user root
instead of user yael
- You can use the following format:
echo "10.10.10.10 yael_host" | sudo tee --append /etc/hosts
or
sudo sh -c "echo '10.10.10.10 yael_host'>>/etc/hosts"
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加