【问题标题】:How to append to /etc/hosts file from the termimal? [duplicate]如何从终端附加到 /etc/hosts 文件? [复制]
【发布时间】:2014-12-13 18:37:37
【问题描述】:

我正在尝试从终端附加到 /etc/hosts 文件:

sudo echo -e "127.0.0.1      localhost-myproject" >> /etc/hosts

即使我使用 sudo,它也不会让我这样做。我的权限被拒绝:

bash: /etc/hosts: Permission denied

我看过其他几个帖子,他们是这样指导的。但我收到了这个错误。我怎样才能做到这一点?谢谢

【问题讨论】:

    标签: linux shell hosts


    【解决方案1】:

    sudo /bin/bash -c 'echo -e "127.0.0.1 localhost-myproject" >> /etc/hosts'

    【讨论】:

    • 在 ubuntu 16 上工作
    猜你喜欢
    • 2013-10-20
    • 1970-01-01
    • 1970-01-01
    • 2012-03-05
    • 1970-01-01
    • 2014-08-04
    • 1970-01-01
    • 1970-01-01
    • 2022-12-24
    相关资源
    最近更新 更多