ZhangZhihui's Blog  

scnzzh@ZUBT:~$ sudo echo -e 'devops\tALL=(ALL)\tNOPASSWD:\tALL' > /etc/sudoers.d/devops
bash: /etc/sudoers.d/devops: Permission denied

 

The redirection is done by the shell before sudo is even started. So either make sure the redirection happens in a shell with the right permissions

sudo bash -c 'echo "hello" > f.txt'

or use tee

echo "hello" | sudo tee f.txt  # add -a for append (>>)
posted on 2020-10-20 09:57  ZhangZhihuiAAA  阅读(229)  评论(0编辑  收藏  举报