Interface 如何在没有gedit的情况下修改/etc/网络/接口?

Interface 如何在没有gedit的情况下修改/etc/网络/接口?,interface,permissions,gedit,Interface,Permissions,Gedit,我正在做一个脚本,我想添加以下行 pre-up iptables-restore < /etc/iptables.rules 预备份iptables还原

我正在做一个脚本,我想添加以下行

pre-up iptables-restore < /etc/iptables.rules
预备份iptables还原
到位于/etc/network/interfaces上的文件接口,但是尽管我已经启用了在这个文件中写入的权限(我在Ubuntu中工作),但我不能这样做。。。我试图在bash脚本中使用以下命令

sudo echo "pre-up iptables-restore < /etc/iptables.rules" >> /etc/network/interfaces
sudo echo“预备份iptables还原/etc/network/interfaces
有没有关于如何在不使用gedit o vi的情况下执行此操作的建议


提前谢谢

在启动sudo之前,您需要告诉bash不要使用重定向:

sudo bash -c 'echo "pre-up iptables-restore < /etc/iptables.rules" >> /etc/network/interfaces'
sudobash-c'echo“预备份iptables还原”/etc/network/interfaces”

这样,完整的命令将通过root访问执行,而不仅仅是
echo“pre-up iptables restore
part

我认为它不能正常工作,因为我被检索到了这个消息sudo:echo“pre-up iptables restore/etc/network/interfaces:command not found现在它可以工作了!谢谢,我知道我应该将整个选项作为命令传递