向特权文件重定向输出内容

109 阅读1分钟
  1. 如果使用echo "some thing" >> <privileged_file>,则会提示错误如下。
-bash: file1: Permission denied

这种场景下使用如下方式 $ echo "some thing" | sudo tee -a file1

  1. 还可以用如下方式
$ sudo tee <file1> <<-'EOF'
some thing
EOF