须藤回声"东西" >>在/ etc / privilegedFile不工作...是否有别的选择吗?

须藤回声"东西" >>在/ etc / privilegedFile不工作...是否有别的选择吗?

问题描述:

这是一个pretty简单的问题,至少现在看来似乎应该是,大约在Linux中sudo的权限。

This is a pretty simple question, at least it seems like it should be, about sudo permissions in Linux.

有很多时候,我只是想将一些东西附加到 / etc / hosts中或类似的文件,但最终没有能够因为两个> >方式> 是不允许的,即使有根

There are a lot of times when I just want to append something to /etc/hosts or a similar file but end up not being able to because both > and >> are not allowed, even with root.

有什么方法来完成这项工作,而无需须藤苏成根?

Is there someway to make this work without having to su or sudo su into root?

使用三通:

echo 'deb blah # blah' | sudo tee --append /etc/apt/sources.list

请一定要避免引号内的报价。

Make sure to avoid quotes inside quotes.

要避免打印数据传回控制台:

To avoid printing data back to the console:

echo 'deb blah # blah' | sudo tee --append /etc/apt/sources.list > /dev/null