gpt4 book ai didi

linux - 使用 cat 命令作为编辑器时出现权限错误

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:21:46 26 4
gpt4 key购买 nike

<分区>

以下命令按预期工作:

# Add/create /tmp/hosts with the string content inside EOFs
$ cat >> /tmp/hosts <<EOF
127.0.0.0 example.com
127.0.0.0 foo.example.com
EOF

但是,即使 sudo 的帐户具有写入 /etc/hosts 的权限,以下命令也会产生错误。

$ sudo cat >> /etc/hosts <<EOF
127.0.0.0 example.com
127.0.0.0 foo.example.com
EOF

-bash: /etc/hosts: Permission denied

为什么?以及如何才能准确实现上述命令的目的?

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com