尝试将文件附加到使用sudo根拥有的文件时,权限被拒绝 [英] Permission denied when trying to append a file to a root owned file with sudo
本文介绍了尝试将文件附加到使用sudo根拥有的文件时,权限被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是导致权限被拒绝的shell命令时,我想在一个文件中的数据追加到使用sudo另一个文件:
This is the shell command that results in "Permission denied" when I'm trying to append the data in a file to another file with sudo:
sudo cat add_file >> /etc/file
在的/ etc /文件
是国有根
(即我)和它的权限是<$文件C $ C> RW-R - R的 - 。我应该成为根
片刻,使其工作或者是有须藤
?
The file at /etc/file
is owned by root
(i.e. me) and its permissions are rw-r--r--
. Should I become root
for a moment to make it work or is there a workaround for sudo
?
推荐答案
运行庆典
为须藤
:
$ sudo bash -c "cat add_file >> /etc/file"
$ whoami;sudo bash -c "whoami";whoami
iiSeymour
root
iiSeymour
这篇关于尝试将文件附加到使用sudo根拥有的文件时,权限被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文